Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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);
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);
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
I think i´ll have to erase this thread and create another because nobody understaund what i say. My english is too bad.
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);
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
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.
yes u need to use the sum columns to reload the script without an error when u r using group by.