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

Minimum country medals by year

So far, you've seen MAX and SUM, aggregate functions normally used with GROUP BY, being used as window functions. You can also use the other aggregate functions, like MIN, as window functions.

Bu egzersiz, kursun bir parçasıdır

PostgreSQL Summary Stats and Window Functions

Kursa Göz Atın

Egzersiz talimatları

  • Return the year, medals earned, and minimum medals earned so far.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

WITH France_Medals AS (
  SELECT
    Year, COUNT(*) AS Medals
  FROM Summer_Medals
  WHERE
    Country = 'FRA'
    AND Medal = 'Gold' AND Year >= 2000
  GROUP BY Year)

SELECT
  ___,
  ___,
  ___ OVER (ORDER BY ___ ASC) AS Min_Medals
FROM France_Medals
ORDER BY Year ASC;
Kodu Düzenle ve Çalıştır