Unpivoting Multiple Sets of Columns in SQL Server using CROSS APPLY
Learn how to unpivot data or sets of data with SQL Server queries using CROSS APPLY.
2023-11-24
Learn how to unpivot data or sets of data with SQL Server queries using CROSS APPLY.
2023-11-24
2023-07-21
462 reads
2023-07-14
474 reads
This script converts hierarchical adjacency into nested json rows which contain the recursive "downlines" of each node. The table-valued function treats each row in the original adjacency as the root node in a recursive common table expression.
2019-11-25 (first published: 2019-11-24)
716 reads
This script converts hierarchical adjacency into nested json rows which contain the recursive "downlines" of each node. The table-valued function treats each row in the original adjacency as the root node in a recursive common table expression.
2019-11-12 (first published: 2019-11-08)
1,983 reads
2015-10-15
1,759 reads
2012-10-01
2,494 reads
The second of a series by Paul White examining the APPLY operator. In this section learn how this operator compares with joins and about both the cross and outer options.
2012-01-13 (first published: 2010-04-19)
28,031 reads
The first of a two-part series of articles examining the APPLY operator. Learn the basics of how this operator works and how it can help you solve some tricky problems.
2012-01-06 (first published: 2010-04-12)
49,535 reads
By Steve Jones
I looked at row_number() in a previous post. Now I want to build on...
Recently I received a cry for help over Teams. The issue was that an...
By davebem
I was the principal author of this SIOS whitepaper, which describes how to build...
Hi - I'm looking for advice regarding the best & quickest way to establish...
Hello. I am looking for a tool Data cleansing/conversion, was recommended HPE any...
I have a query that runs in a job to check on orphaned users....
I have this data in a SQL Server 2022 table:
player yearid team HR Alex Rodriguez 2012 NYY 18 Alex Rodriguez 2013 NYY 7 Alex Rodriguez 2014 NYY NULL Alex Rodriguez 2015 NYY 12 Alex Rodriguez 2016 NYY 9If I run this code, what are the results returned in the hrgrowth column?
SELECT player , yearid , hr , hr - LAG (hr, 1, 0) IGNORE NULLS OVER (ORDER BY yearid) AS hrgrowth FROM dbo.playerstats;See possible answers