Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL Statement doesn't work

Hi to All!!!

i have one sql statement but it doesnt work on Qlikview, but it does in SQL:

Transac:

LOAD

IdentifEspacio,

HoraInicio_EC,

HoraFin_EC,

PautaId,

AnoMes,

HoraInicio_OC,

HoraFin_OC,

CantSalidas,

DuracionTot,

VigDesde_CV,

VigHasta_CV,

Frecuencia_CV,

Horario,

Version

;

SQL SELECT EspacioCont.IdentifEspacio, EspacioCont.HoraInicio as HoraInicio_EC, EspacioCont.HoraFin as HoraFin_EC,

OrdenadoCab.PautaId, OrdenadoCab.AnoMes, OrdenadoCab.HoraInicio as HoraInicio_OC, OrdenadoCab.HoraFin as HoraFin_OC, OrdenadoCab.CantSalidas, OrdenadoCab.DuracionTot,

CostoVersion.VigDesde as VigDesde_CV, CostoVersion.VigHasta as VigHasta_CV, CostoVersion.Frecuencia as Frecuencia_CV, CostoVersion.Horario, CostoVersion.Version

FROM

  Publicidad.dbo.EspacioCont ,

  Publicidad.dbo.OrdenadoCab ,

  Publicidad.dbo.CostoVersion

where

  EspacioCont.IdentifEspacio = 'AMER-INTR-PROG' and

  OrdenadoCab.IdentifEspacio = EspacioCont.IdentifEspacio and

  CostoVersion.IdentifEspacio = OrdenadoCab.IdentifEspacio and

  CostoVersion.Version = (select max(CostoVersion.version)

                    from Publicidad.dbo.CostoVersion

                    where CostoVersion.IdentifEspacio = EspacioCont.IdentifEspacio

                    group by CostoVersion.IdentifEspacio)

order by

  EspacioCont.IdentifEspacio;

Why doesnt return me any row???  In Sql the query HAVE 28 rows...

Any Idea?

Thanks to all!

20 Replies
Not applicable
Author

When i uncomment the LOAD part...  it works with no errors, but doesnt returns me any row...

But only the SQL statement returns me ODBC Error...

Thanks anyway Michael

Anonymous
Not applicable
Author

I see...  It is a known bug - script doesn't return error and loads nothing, although there is an error.  At least you found out that the error is on the SQL SELECT level.

If this SELECT works outside of QV, the problem most likely with ODBC.  I hope you'll be able to resolve it by using OLEDB.  Or fix the query if needed.

Regards,

Michael

rbecher
MVP
MVP

Hi German,

I think the group by clause could be a problem. I would omit it because it could lead into a return of multiple rows which then could fail the condition CostoVersion.Version = max(CostoVersion.version):

CostoVersion.Version = (select max(CostoVersion.version)

                    from Publicidad.dbo.CostoVersion

                    where CostoVersion.IdentifEspacio = EspacioCont.IdentifEspacio

                    group by CostoVersion.IdentifEspacio)

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
Anonymous
Not applicable
Author

Makes sense, "group by" is not needed here.

My understanding was that the query worked in SQL.  But it is data-sensitive, hence not reliable.

rbecher
MVP
MVP

Maybe different handling with ODBC then in database itself..

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
Anonymous
Not applicable
Author

Exactly what I think

Not applicable
Author

But... it works well in SQL...  why doesnt in Qlikview????

Not applicable
Author

Nop... i had try with OLEDB and doesnt work either....

Anonymous
Not applicable
Author

Because, as Ralf Becher said, "different handling with ODBC then in database itself".

Try OLEDB connection.

Not applicable
Author

Can you post sample data from three table and sample qvw