Is it possible for a SQL query to return some normal columns and some aggregate ones?
like :
Col_A | Col_B | SUM
------+-------+------
5 | 6 | 7
Is it possible for a SQL query to return some normal columns and some aggregate ones?
like :
Col_A | Col_B | SUM
------+-------+------
5 | 6 | 7
Yes of course. Read on GROUP BY and aggregate functions. e.g.
Yes, add them to GROUP BY clause.
You can show ordinary columns or expressions based on ordinary columns, but only if they are included in the set of columns/expressions you are agregating over ( what is listed in Group By clause ).
You should use the group by statement.
For example:
You can see a complete example here.
If you GROUP BY some fields, you can show those fields, and aggregate others; e.g.:
aggregation can be by SUM, MIN, MAX, etc.