This video is part of a multi-part series on mastering the SQL SELECT statement. The SELECT statement, the most often used SQL command, is easy to learn yet difficult to master. Follow along with me and level up your database query super powers!
This video covers Window functions which appear in the projection and operate over the common-table expression, producing a single value in each row. Window functions make it easier for us to write complex SQL queries without the need to write sub-queries or use the WITH clause.
Window functions return a value in the row/column intersection based on the selected partition of data in the common table expression of the query.
The video demonstrates the three types of window functions:
1. Aggregate window functions like SUM(), MIN(), MAX(), AVG(), and COUNT() that return a summary value based on the chosen partition.
2. Value window functions like LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE() that retrieve a positional value based on the chosen partition and sort order
3. Ranking window functions like ROW_NUMBER(), RANK() and NTILE() that return an ordinal position as it value based on the chosen partition and sort order.
The SQL code is available here: https://github.com/mafudge/learn-data...
If you need to setup your own database environment, check out learn-databases! The easy way to get going and follow along with these videos. • Learn Databases Walkthrough
This video is part of the textbook Applied Database Management https://applieddb.com
Here's the entire playlist: • Applied Database Management with SQL