
GROUP BY: Aggregating Your Data
Last week, we learned to use WHERE to efficiently return only the rows that we want from a database. But what if you want to summarize the data more efficiently? It turns out that you can have the database do the summarization for you with the GROUP BY keyword. Like Python’s collections.Counter or pandas groupby(), SQL’s GROUP BY lets you summarize data by category. It allows you to count, sum, and average across groups. ...







