Reading Time: 2 minutesThe SQL Server WINDOW clause is a new feature introduced in Microsoft SQL Server 2022. It can make the syntax of a window query much more readable. In this brief tutorial, we’ll walk through how the WINDOW clause works and see how it can be very helpful. Start with a Continue Reading
Window functions
SQL Server QUALIFY: Doesn’t Exist, Do THIS Instead
Reading Time: 3 minutesSQL Server has many useful window functions available to us that can make the task of gathering aggregate/ranking/offset data very easy. One tool that you might have heard of is the QUALIFY clause. This tool can be used to filter the result of a window function. The problem is that Continue Reading
How To Get a Running Total of Your SQL Data: Explained for Beginners
Reading Time: 5 minutesIn this very brief tutorial, we’ll discuss how to gather a very particular kind of SQL data: A running total. The best way I found to gather a running total (sometimes called a rolling total) of SQL data is to… Use the SUM() aggregate window function There might be other Continue Reading
SQL Server NULLIF: Explained for Beginners
Reading Time: 5 minutesThere are many ways we can compare the equivalency of two values in Microsoft SQL Server. We can use the regular equals ( = ) operator in an IF statement, for example, or we can use the handy CASE statement within the column list of a SELECT statement. But there Continue Reading
What’s the difference between ROWS and RANGE? Explained!
Reading Time: 5 minutesWindow functions are a great thing to know when querying data in a Microsoft SQL Server database. If you need an introduction to SQL Server window functions, you should definitely check out my full tutorial on the topic: SQL Server Window Functions: An introduction for beginners Also, all the information Continue Reading
SQL LAG and LEAD Window Functions: Explained
Reading Time: 9 minutesThe SQL Server LAG and LEADÂ functions are simple window functions you should know to help you gather meaningful information from your data. Window functions are considered an advanced tool when querying data in SQL Server. If you’re trying to learn about window functions, congratulations, you’re moving up! The LAG and Continue Reading
FIRST_VALUE and LAST_VALUE: SQL window functions you should know
Reading Time: 9 minutesThe SQL Server FIRST_VALUE and LAST_VALUE functions are simple window functions you should know to help you gather meaningful information from your data. Window functions are considered an advanced tool when querying data in SQL Server. If you’re trying to learn about window functions, congratulations, you’re moving up! The FIRST_VALUE Continue Reading
SQL Server Offset Window Functions: FIRST_VALUE, LAST_VALUE, LAG, LEAD
Reading Time: 12 minutesOffset window functions are very useful tools you should know when querying databases in Microsoft SQL Server. There are several different window functions available to us. You should know all of them if you want to be the world’s best database developer. In this tutorial, we’re going to discuss the four Offset Continue Reading
What’s the difference between RANK and DENSE_RANK? Answered!
Reading Time: 5 minutesThe RANK and DENSE_RANK window functions in SQL Server are very handy when you need to gather ranking information from your data. But do you know the difference between the two? The difference is subtle, but important. This tutorial assumes you know a thing or two about window functions in Continue Reading
NTILE window function: How it works
Reading Time: 6 minutesThe NTILE window function in Microsoft SQL Server can be used to rank data in a dataset. This function is definitely worth knowing if you want to learn all there is to know about querying data in SQL Server. In this brief tutorial, we’ll discuss what the NTILE function is Continue Reading