SQL Window Functions Series: LAG() and LEAD()
Dive deep into the powerful SQL window functions, LAG() and LEAD(). Explore their intricacies, discover real-world examples, and avoid common pitfalls.
2023-12-11
7,845 reads
Dive deep into the powerful SQL window functions, LAG() and LEAD(). Explore their intricacies, discover real-world examples, and avoid common pitfalls.
2023-12-11
7,845 reads
The most common method on the internet for combining DATE and TIME columns in SQL Server is incorrect. This article demonstrates why that and other methods are incorrect and two lesser known high performance methods that produce correct results even for the "edge cases".
2023-08-07
21,885 reads
Learn to calculate Start / First of Week, End of Week, Start of Next Week, Year, Quarter, and Month of the week, Week Numbers and more in T-SQL (Jeff Moden)
2022-07-13
32,042 reads
A function to add or subtract working days taking into account weekends and using a table of non-working days.
2019-07-10 (first published: 2019-06-26)
5,170 reads
2018-02-23 (first published: 2018-02-19)
152 reads
2017-12-29
1,088 reads
This script provides the day of the month for the standard bank holidays for any given year. This is especially useful for computing the workday after a holiday.
2017-05-24 (first published: 2017-05-10)
498 reads
By Steve Jones
A friend was asking for help with some data analysis. This was in PowerBI,...
I am responding late to a T-SQL Tuesday invite from John Sterrett. John’s call...
It’s been forgotten about and neglected for few years but I’ve decided to dust...
Comments posted to this topic are about the item How a Legacy Logic Choked...
Comments posted to this topic are about the item People Make Odd Choices
Comments posted to this topic are about the item SQL Server 2022 Clusterless Distributed...
For the Question of the day, I am going to go deep, but try to be more clear, as I feel like I didn't give enough info last time, leading folks to guess the wrong answer... :) For today's question: You’re troubleshooting a performance issue on a critical stored procedure. You notice that a previously efficient query now performs a full table scan instead of an index seek. Upon investigating, you find that an NVARCHAR parameter is being compared to a VARCHAR column in the WHERE clause. What is the most likely cause of the query plan regression?
See possible answers