← SQL tutorial

SQL

Aggregate Functions

Aggregate functions compute a single value across many rows: COUNT() counts rows, SUM() totals a column, AVG() averages it, MIN()/MAX() find the smallest/largest value.

Example: an average score per track

SELECT track, AVG(score) AS avg_score
FROM students
GROUP BY track;
track         | avg_score
Frontend      | 90.0
Cybersecurity | 78.0
Backend       | 85.0

Without GROUP BY, AVG(score) alone would collapse the entire table into one single average across every student. Adding GROUP BY track changes that completely: it computes a separate average for each distinct track value, producing one row per group instead of one row total, the difference between "what's the average score overall" and "what's the average score, broken down by track," which is a genuinely different, much more useful question.

Example
SELECT track, AVG(score) AS avg_score
FROM students
GROUP BY track;
Output
track         | avg_score
Frontend      | 90.0
Cybersecurity | 78.0
Backend       | 85.0
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Backend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account