Volleynerd Knowledge Base

Monday, April 22, 2002


SQL GroupBy


Never realized you could get the count and sum of many different columns in a query. The trick is that everything in the "select" clause must be in the "group by" clause. When using the group by, think of it like jamming all those columns together - as long as there's something unique in at least one of the columns, it'll come out as a different group.


select [a,b,c...] , sum(d), sum(e), count(f)
from tableA, tableB
where tableA.ID = tableB.ID
group by [a,b,c...]




Comments: Post a Comment

Home