Cleaning up results
Returning to the breakdown of Scandinavian awards you previously made, you want to clean up the results by replacing the null
s with meaningful text.
This exercise is part of the course
PostgreSQL Summary Stats and Window Functions
Exercise instructions
- Turn the
null
s in theCountry
column toAll countries
, and thenull
s in theGender
column toAll genders
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT
-- Replace the nulls in the columns with meaningful text
___(Country, ___) AS Country,
___(Gender, ___) AS Gender,
COUNT(*) AS Awards
FROM Summer_Medals
WHERE
Year = 2004
AND Medal = 'Gold'
AND Country IN ('DEN', 'NOR', 'SWE')
GROUP BY ROLLUP(Country, Gender)
ORDER BY Country ASC, Gender ASC;