B · Analyze · intermediate · Week 2 · Chapter 6 of 12
Aggregations & GROUP BY
COUNT, SUM, AVG, MIN, MAX. GROUP BY for per-category stats. HAVING filters groups after aggregation.
Path progress44%
Step 1 of 3
Aggregates
COUNT(*), SUM(amount), AVG(price). Non-aggregated columns must appear in GROUP BY.
Example
SELECT
COUNT(*) AS order_count,
SUM(total) AS revenue,
AVG(total) AS avg_order
FROM orders;Do this now
Total revenue, order count, average order value from orders table.
Was this step clear?
Chapter learning outcomes
- Aggregate functions
- GROUP BY
- HAVING vs WHERE
- Query grain
Clear these before you leave
Side quest
Funnel counts
Group events by step_name; count users per step.