in reply to (somewhat OT) Seeking a SQL counter-example
ID | SalesID | CityID | Money |
---|---|---|---|
1 | 10 | 20 | 1000 |
2 | 10 | 22 | 2000 |
3 | 11 | 20 | 4000 |
4 | 11 | 22 | 8000 |
5 | 10 | 20 | 3000 |
6 | 10 | 22 | 5000 |
7 | 11 | 20 | 7000 |
8 | 11 | 22 | 9000 |
select from table SalesID,CityID,Sum(Money) Groupby SalesID,CityID -- or select from table SalesID,CityID,Sum(Money) Groupby CityID, SalesID
Those should vary only in output order of the summed rows. The danger of automatic grouping is when/if someone picks "ID" in the select list... then it all goes to heck. The "common case" for Group By is to list all columns not aggregated in the select_column clause. Automatically forcing group-by seems to be almost assuredly doomed to run into keys and foreign-keys when they are incorrectly added to the columns list.
In your limited case, tho, I'm thinking you're safe.
--
$you = new YOU;
honk() if $you->love(perl)
In Section
Seekers of Perl Wisdom