Aggregate Functions
The requests you’ve been working with so far have required answers involving individual column values from the rows returned by the FROM and WHERE clauses. However, you’ll often encounter requests, such as the following, that require only calculated values across multiple rows for an answer.
“How many of our customers live in Seattle?”
“What is the lowest price and highest price we’ve assigned to any item in our inventory?”
“How many classes is Mike Hernandez teaching?”
“What time does our earliest class begin?”
“What is the average length of a class?”
“What is the total amount for order number 12?”
The SQL Standard provides a set of aggregate functions that allow you to calculate a single value from the rows in a result ...
Get SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.