Country-स्तर के subtotals
आप 2004 में तीन स्कैंडिनेवियाई देशों के लिए, प्रति देश और gender के हिसाब से जीते गए gold medals देखना चाहते हैं। आप Country-स्तर के subtotals में भी रुचि रखते हैं ताकि हर देश के कुल medals मिल सकें, लेकिन Gender-स्तर के subtotals इस मामले में बहुत उपयोगी नहीं हैं, इसलिए उन्हें नज़रअंदाज़ करें.
यह अभ्यास पाठ्यक्रम का हिस्सा है
PostgreSQL Summary Stats और Window Functions
अभ्यास निर्देश
- प्रति देश और gender दिए गए gold medals की गणना करें.
Country-स्तर के gold award counts जनरेट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
-- Count the gold medals per country and gender
SELECT
___,
___,
COUNT(*) AS Gold_Awards
FROM Summer_Medals
WHERE
Year = 2004
AND Medal = 'Gold'
AND Country IN ('DEN', 'NOR', 'SWE')
-- Generate Country-level subtotals
GROUP BY ___, ___
ORDER BY Country ASC, Gender ASC;