Skip to content

PostgreSQL Summary Stats and Window Functions

Here you can access the summer_medals table used in the course. To access the table, you will need to specify the medals schema in your queries (e.g., medals.summer_medals).


Note: When using sample databases such as those that contain course data, you have read-only access. You can run queries, but cannot make any changes such as adding, deleting, or modifying the data (e.g., creating tables, views, etc.).

Take Notes

Add notes about the concepts you've learned and SQL cells with queries you want to keep.

Add your notes here

Spinner
DataFrameas
movie_info
variable
-- Add your own queries here
WITH datacamp_workspace__user_query AS (
    SELECT year, country, COUNT(medal) AS Medals,
        ROW_NUMBER() OVER(PARTITION BY year ORDER BY COUNT(medal) DESC) AS ROW_N
    FROM medals.summer_medals
	WHERE year IN (2004, 2008)
    GROUP BY year, country
)

SELECT * FROM datacamp_workspace__user_query
LIMIT 6

Find in the hidden cell below some exercises to explore the data and practice your skills:


1 hidden cell