Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ORDER BY in a table with joins

Hi everybody. I´m having problems with this easy thing.

I have this and i dont know where put the ORDER by,  i tried a few examples but they don't work.

SDS:

LOAD

  EMPRESA,         

  DIVISION_A,

RESIDENT TMP_SALDOSINICIALES

GROUP BY

  EMPRESA,

  DIVISION_A,

DROP TABLE TMP_SALDOSINICIALES;

left join

LOAD DISTINCT

  YEAR

FROM

[DIARIO.QVD]

(qvd);

16 Replies
MK_QSL
MVP
MVP

Group by can be used if you are aggregating something on script lever... Example shown below

Sales:

Load Customer, Date, Sales From TableName;

TotalSales:

Load Customer, SUM(Sales) as TotalSales Resident Sales Group By Customer;

Hope this will clear your doubt...

Anonymous
Not applicable
Author

Hi,

Group by will work only if there is any aggr functions such as min,max,avg,count,sum etc is defined for that table.

Not applicable
Author

sory i made a mistake

i wanted to say ORDER BY i was thinking in another thing

its_anandrjs

Load your table like

tmpSDS:

LOAD

  EMPRESA,        

  DIVISION_A,

RESIDENT TMP_SALDOSINICIALES

DROP TABLE TMP_SALDOSINICIALES;

left join

LOAD DISTINCT

  YEAR

FROM

[DIARIO.QVD]

(qvd);

Noconcatenate

FinalTable:

LOAD

  EMPRESA,        

  DIVISION_A,

RESIDENT tmpSDS

Order BY

  EMPRESA,

  DIVISION_A;

Drop Table tmpSDS;

Check this script

Regards,

Anand

Not applicable
Author

sory i made a mistake

i wanted to say ORDER BY i was thinking in another thing

MK_QSL
MVP
MVP

//Hoping that  TMP_SALDOSINICIALES already loaded in the script before using Resident TMP_SALDOSINICIALES

NoConcatenate

SDS:

LOAD

  EMPRESA,         

  DIVISION_A,

RESIDENT TMP_SALDOSINICIALES

Order BY  EMPRESA,   DIVISION_A;

DROP TABLE TMP_SALDOSINICIALES;

left join

LOAD DISTINCT

      YEAR

FROM

[DIARIO.QVD]

(qvd);

Not applicable
Author

Yeah, thats right. The table tmp_saldos is loaded.

But i dont see the group by in that table. My table is this and in this way it´s works fine

SDS:

LOAD

  EMPRESA,        

  DIVISION_A,

RESIDENT TMP_SALDOSINICIALES

GROUP BY

  EMPRESA,

  DIVISION_A,

DROP TABLE TMP_SALDOSINICIALES;

left join

LOAD DISTINCT

  YEAR

FROM

[DIARIO.QVD]

(qvd);

Thank you!

MK_QSL
MVP
MVP

I am confused now.... You want order by or group by?

Not applicable
Author

I wasn´t very clear, sory for that. I have that table with a group by. It´s work fine.

I want to have an order by in that table.