CodeAgeBy Sitezack
Your data, your database 🗄️SQL with real data0 XP
Chapter progress0/5

Lesson 5 of 6

COUNT and SUM: do the math

Aggregate functions summarize rows: COUNT(*) counts, SUM(column) adds up. With GROUP BY, the math is done per group.

On a social network, the posts table has an author and likes. GROUP BY author gives one row per person.

SELECT author, COUNT(*) FROM posts GROUP BY author;

🎯 Your goal

Per author: the number of posts (COUNT(*)) and the total likes (SUM(likes)). Group by author and sort by author.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO