Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Learn what SQL Window Functions are and why they're useful.
Follow along with this workshop:
You can download the database used in this workshop from the Downloads tab and load it into the database of your choice. Or, you can use Mode Analytics, an online database and SQL reporting service. You can create a free account and use our free data-source for this workshop:
- Create a free account on Mode: https://modeanalytics.com/signup
- Create a new Mode Report
- For the "data source" select the Mode Public Warehouse
- Use the
treehouse.chess_data_matches
table
You can then execute the SQL that we show you here in Mode.
Definitions:
Window function An SQL function that aggregates over the results of the query.
PostgreSQL Download
SQL from Video
SELECT PLAYER_NAME,
PLAYER_RANKING,
PLAYER_TEAM,
COUNT(MATCH_ID) AS MATCHES_PLAYED,
SUM(CHECKMATE) AS MATCHES_WON,
SUM(CHECKMATE)/COUNT(MATCH_ID) AS WIN_RATE
FROM treehouse.chess_data_matches
GROUP BY PLAYER_NAME,
PLAYER_RANKING,
PLAYER_TEAM
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up