PivotTables in SQL: GROUP BY & HAVING Explained for Excel Users
Dragging a field into PivotTable Rows and Values is identical to writing SQL GROUP BY with SUM, COUNT, and AVG.
By Victor Wachira · Founder, Sumwise · 5 min read
Rows = GROUP BY, Values = SUM / COUNT / AVG
Whenever you drag Region into PivotTable Rows and Revenue into Values (Sum), you are running SELECT region, SUM(revenue) FROM sales GROUP BY region. Every non-aggregated column in SELECT belongs in GROUP BY.
WHERE vs HAVING (Row Filter vs Value Filter)
In Excel, filtering raw rows before building a PivotTable is SQL WHERE. Applying a Value Filter on the summarized totals (e.g. only regions over $10,000) is SQL HAVING SUM(revenue) > 10000.
Put this into practice in 4 minutes
Try real interactive Excel, Google Sheets, and SQL exercises — every core lesson is free to study.
Free 1-Page Excel, Google Sheets & SQL Interview Cheat Sheet
The 25 formulas, keyboard shortcuts, and SQL patterns tested most in analyst interviews — emailed instantly, zero spam.