SQL Aggregation #
Do some calculations.
Other than count(), many of the methods require numeric value types.
COUNT() #
SELECT count(*) --or <field(s)>
FROM <table>;
Extend with conditions
SELECT count(*) --or <field(s)>
FROM <table>
WHERE <condition>;
SUM() #
SELECT sum(<field>)
FROM <table>;
MAX() #
SELECT MAX(<field>)
FROM <table>;
MIN() #
SELECT MIN(<field>)
FROM <table>;
AVG() #
SELECT MIN(<field>)
FROM <table>;
ROUND() #
round(<field>, <integer>)
, where the integer specifies the number of decimal place s to round to.
GROUP BY #
Aggregate by a particular group
SELECT <field>
FROM <table>
GROUP BY <categorical field>;
GROUP BY
can also be performed on a calculation.