Aggregations
Aggregators only aggregate vertically - the values of a column.
SQL evaluates the aggregations before the
LIMIT
clause.
COUNT
COUNT
SUM
SUM
Unlike COUNT
, you can only use SUM
on numeric columns. However, SUM
will ignore NULL
values.
MIN
, MAX
& AVG
MIN
, MAX
& AVG
GROUP BY
GROUP BY
used to aggregate data within subsets of the data.
Any column in the
SELECT
statement that is not within an aggregator must be in theGROUP BY
clause.You can GROUP BY multiple columns at once, The order of column names in your GROUP BY clause doesn’t matter—the results will be the same regardless.
DISTINCT
DISTINCT
using DISTINCT
, particularly in aggregations, can slow your queries down quite a bit.
HAVING
DATE Functions
CASE Statements
The CASE statement always goes in the SELECT clause.
CASE must include the following components: WHEN, THEN, and END. ELSE is an optional component to catch cases that didn’t meet any of the other previous CASE conditions.
Last updated
Was this helpful?