Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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
Anonymous
Not applicable
Author

I think that u r expecting something like this

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

Ok but i dont have the group by in that table. I need to have the group by, i dont have problems with that. I need to order the table WITH the group by.

thank you

Not applicable
Author

I think i´ll have to erase this thread and create another because nobody understaund what i say. My english is too bad.

Anonymous
Not applicable
Author

What do u need to find with the help of group by?

if u want to use group by then u should be using some aggr function like this:

This script will give the same result  as the above script

SDS:

LOAD

  EMPRESA,      

  DIVISION_A,

Count(1)  as count

RESIDENT TMP_SALDOSINICIALES

GROUP BY EMPRESA, DIVISION_A

ORDER By  EMPRESA, DIVISION_A;

DROP TABLE TMP_SALDOSINICIALES;

left join

LOAD DISTINCT

  YEAR

FROM

[DIARIO.QVD]

(qvd);

its_anandrjs

You have to do that after doing the Group By to the Order By on the same table but on the resident load table see example for that.

tmpSDS:

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);

Noconcatenate

FinalTable:

LOAD

  EMPRESA,          

  DIVISION_A

  YEAR

RESIDENT tmpSDS

ORDER BY

  EMPRESA,

  DIVISION_A;

Drop Table tmpSDS

Hope this helps

Anand

Not applicable
Author

Ahhhh ok now i understaund why you were confused. I borrow a lot of columns to make more easy to read, and i deleted the function. yeah, i have a sum in the table.

do i have to have the same columns in the group by and the order by ? i dont know why i have the error.

Anonymous
Not applicable
Author

yes u need to use the sum columns to reload the script without an error when u r using group by.