top of page

SQL GROUP BY and SUM

Updated: May 1

The countries table includes the population of each country. But what if we wanted to know the population of each continent? We need to use: in SQL we use: GROUP BY.

Use GROUP BY and SUM() to calculate the total population of each continent. Select only the continent column and the sum.


Answer: SELECT continent, SUM(population)

FROM countries

GROUP BY continent


Ready to become a SQL wizard in record time? Dive into the world of databases with our SQL Bootcamp!



Whether you're a complete beginner or looking to brush up on your skills, "Mastering SQL" is your ticket to proficiency.





MySQL

172 views0 comments

Comentários


bottom of page