So far I have written Aggregate function followed by Group By clause to find the values based on SUM, AVG and other Aggregate functions. I have a bit confusion in the Group By clause.
When we use Aggregate functions what are the columns I need to specify in the Group By clause.
Otherwise Is there any way to use Aggregate functions without using Group By clause.
So far I have written Aggregate function followed by Group By clause to find
Share
All columns in the SELECT clause that do not have an aggregate need to be in the GROUP BY
Good:
Also good:
No other columns = no GROUP BY needed
Won’t work:
Pointless:
Having an aggregate (MAX etc) with other columns without a GROUP BY makes no sense because the query becomes ambiguous.