Count and count distinct
By pure numbers, the greater a country's population, the greater the pool of athletes and thus Olympians. You decide to look at Olympic medals based purely on population, or volume of available athletes.
The World Bank data shows that in 2016, the countries with the highest populations were China (1,378,665,000), India (1,324,171,354), and the United States of America (323,405,935).
Now you will look at the Olympic athletes' data from the 2016 Summer Olympics to see if China, India, and the USA did indeed win the most medals.
This exercise is part of the course
Improving Query Performance in PostgreSQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT ___
, ___(___) as medals_count
FROM athletes_recent
WHERE medal IS NOT NULL
AND year = 2016
___ ___
ORDER BY medals_count DESC;