We use cookies to enhance your experience on the site
CodeWorlds

The Hall of Numbers

Welcome back, @name! We venture deeper into the walls of the Great Library. Before you lies the Hall of Numbers - a chamber where scribes do not read single scrolls, but count, sum and measure whole shelves at once.

So far you have learned to select and filter individual books. Now I will teach you to look at data from a bird's eye view. Instead of asking "which books are these?", we will ask "how many are there?", "what is the average price?", "which shelf is the richest?".

Why do we need numbers?

Imagine the Library's steward asks:

  • How many scrolls do we have in the entire treasury?
  • What is the average value of a book?
  • How many books lie on each thematic shelf?
  • Which categories are so popular that they hold over a hundred volumes?

You cannot answer this by reading scroll after scroll. We need aggregate functions - magical tools that compute a single summary number from hundreds of rows.

What you will learn

In this hall you will learn:

  • aggregate functions: COUNT, SUM, AVG, MIN, MAX,
  • the difference between COUNT(*), COUNT(column) and COUNT(DISTINCT column),
  • GROUP BY - splitting data into groups and counting each separately,
  • HAVING - filtering whole groups by an aggregate result,
  • the difference between WHERE and HAVING.

Take up your abacus, scribe. The Hall of Numbers awaits!

Go to CodeWorlds