CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Improving Query Performance in PostgreSQL

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

SELECT ___
  , ___(___) as medals_count
FROM athletes_recent
WHERE medal IS NOT NULL
AND year = 2016
___ ___
ORDER BY medals_count DESC;
Modifier et exécuter le code