Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have a table that I want to use Group By, but cannot seem to figure myself out here.
My load script:
Load
[Date from],
[Date to],
Supplier,
[Contract number],
Code
From myTable;
When I add the Group By clause after the 'From' section, I get the error that something is wrong near 'group'.
I want to group by Supplier and Contract number.
Any ideas how to fix this?
Hi @ben0109 ,
You have to check what do you want to group as aggregation, for example count Codes, or sum anything else.
Then the fields you want to group by , they have to be in yor load , you can try something like this :
TableA:
Load
[Date from],
[Date to],
Supplier,
[Contract number],
Code
From myTable;
//groping table
TableB:
Load
Supplier,
[Contract number],
count(Code) as CodeQuantity
Resident TableA
group by
Supplier,
[Contract number];
I don't see why group by required. But you must use group by when you have aggregate functions. Syntax will be after table..
Hi @ben0109 ,
You have to check what do you want to group as aggregation, for example count Codes, or sum anything else.
Then the fields you want to group by , they have to be in yor load , you can try something like this :
TableA:
Load
[Date from],
[Date to],
Supplier,
[Contract number],
Code
From myTable;
//groping table
TableB:
Load
Supplier,
[Contract number],
count(Code) as CodeQuantity
Resident TableA
group by
Supplier,
[Contract number];
As @QFabian and @Anil_Babu_Samineni are writing or are you trying to get the sort order correct? If so then use order by instead of group by.
Order by Supplier, Contract will load your data in the order of the two fields in descending order.
Thanks! The pink part in your answer made it clear.