Re: GROUP BY...easier way to think about it
Posted in 1998
>Hi All,
>
>For goodness sake people, I'm still trying to get my aching brain
>around this thing of GROUP BY :-)
>
>One way I have tried to think about it is to view a GROUP BY statement
>on 1 or more rows as though it were selecting a distinct row. That is:
>
>SELECT field1, field2, field3
>FROM table
>WHERE conditions
>GROUP BY 1, 2, 3>
>Where, in effect, the rows returned will be unique and that the
>combination of the 3 fields is acting as a key.
>
>Er, does anyone follow me or am I barking mad.
>
>Someone pass me a gun :-)
>
>Cheers, Ian.
The mail reason to use a group by is for aggregrate function such as average(),
sum(), max(), etc. Basically this provides the ability to create "subtotals"
by key value. You would group by the "key" columns and sum(), average(),
count(), etc. the other columns.
Madison Pruet