Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with aggregation/group by

Hi everybody,

I have  a general question about group by statements. Right now I have a table where I want to Group based on OrderId but there are several other Fields. Say OrderId is Field 1, Field 2  might have different values but for every OrderId are unique and I have Field 3 which needs to be Summed. So I have the following

LOAD

     Field1,

     Field2,

     SUM(Field3) AS Field

RESIDENT

     Test

GROUP BY Field1

This statement will give an error since i think it is neccessary to include Field2 even tough this field has the same values for each value in Field1. Or I'm I incorrect on this assumption? Can anyone explain the exact rules for the fields which are not aggregated nor grouped but you do want to Load?

1 Reply
Not applicable
Author

Hi

Every field that you use in the table where the group by happens, has to be mandatarily included in the where clause.

however the field used in the aggregation (here: Field 3) need not be included in the table.

So assumption is correct.