Introduction to Window Functions3:58 with Danielle Kiowski
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
You can then execute the SQL that we show you here in Mode.
Window function An SQL function that aggregates over the results of the query.
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
You need to sign up for Treehouse in order to download course files.Sign up