BaşlayınÜcretsiz Başlayın

Group by and aggregations

You decide to take another look at countries with missing population data. You join the World Bank demographics data to the Olympic oregions data.

You want to look at trends so group countries regionally to see how many countries, by region, are missing population data. You know you want to view the results by Olympic region and count the countries with population data using the country code olympic_cc.

Select Run Code to view the results. Did you get an error?

Read the red error message then follow the instructions below to correct the query.

Bu egzersiz

Improving Query Performance in PostgreSQL

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Read the red error output.
  • Change the non-aggregated column in the SELECT clause to match the GROUP BY column .

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

SELECT reg.country, COUNT(DISTINCT dem.olympic_cc)
FROM regions reg -- Olympics region data
LEFT JOIN demographics dem -- World Bank population data
  ON dem.olympic_cc = reg.olympic_cc
GROUP BY reg.region;
Kodu Düzenle ve Çalıştır