Learn how to use analytic SQL functions to deeply understand data.
SQL window functions – also known as windowing functions, OVER functions, or analytic functions – are tremendously useful. These functions make building complex aggregations much simpler. In this step-by-step tutorial, we will lead you through SQL window functions. At its end, you'll embrace this topic with ease and feel comfortable using window functions in SQL databases.
Window functions are so powerful that they serve as a dividing point in time: people talk about SQL before window functions and SQL after window functions. Because they were introduced into the standard relatively recently, these functions aren't covered in many SQL courses.
Note: Most popular database engines support window functions; MySQL is the only one that does not.
This course is intended for intermediate users. We assume the user knows the basics of SQL, including:
You'll also get a deeper understanding of SQL aggregate functions.
Window functions? We'll explain what it's all about.
Your first encounter with window functions.
Get to know tables
Computations with OVER()
Aggregate functions with OVER()
OVER() and WHERE
Discover how you can define the function window with PARTITION BY
Learn how you can rank rows with window functions.
Selecting n-th row
Get to know how to create sophisticated window frames for your window functions.
Default window frame
Learn the most essential analytic functions.
LEAD and LAG
FIRST_VALUE, LAST_VALUE, NTH_VALUE
Create advanced statistics computed independently for various groups of rows.
PARTITION BY ORDER BY with ranking
PARTITION BY ORDER BY with window frames
PARTITION BY ORDER BY with analytical functions
Do you know when window functions are evaluated in a SQL query? Let's find out.
When window functions are evaluated
Window functions and GROUP BY
Master all the skills you acquired so far in our big practice part.
ORDER BY PARTITION BY
Order of evaluation
Test the skills you acquired in the whole course with this final quiz.
5.00 / 5