Aggregates and Grouping
Part of the PostgreSQL course
Somebody asks you how the shop did last month. They do not want the four thousand order rows. They want one number, or maybe one number per customer, and if you pull the rows out and add them up in application code you have just written a slow, fragile version of something the database does natively and instantly. An aggregate is a function that takes many rows and returns one value: a count, a sum, an average.
Open the terminal, give this lesson a fresh database of its own, and connect to it as postgres (lesson 02 explains the sudo -u postgres) ...
Want to learn PostgreSQL Aggregates and Grouping in a real environment?
Click below, get a fresh Linux box with PostgreSQL ready to go, and work through Aggregates and Grouping hands-on with an AI tutor that knows your code.
Start this lessonAggregates and GroupingWhat you'll learn
- COUNT
- SUM
- AVG
- MIN
- MAX
- GROUP BY
- HAVING
- FILTER (WHERE ...)
- DISTINCT
Read this lesson in your language
All lessons in this course
14 lessons- 1What is PostgreSQL20 min
- 2psql and First Commands25 min
- 3Creating Databases and Tables30 min
- 4Data Types25 min
- 5SELECT and WHERE30 min
- 6Joins35 min
- 7Aggregates and Grouping30 min
- 8Indexes35 min
- 9Transactions and Isolation35 min
- 10Functions and Triggers35 min
- 11JSONB and Arrays35 min
- 12EXPLAIN and Query Tuning35 min
- 13Backup and Restore25 min
- 14Capstone: Design a Schema60 min
