|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 6:01 PM
Points: 9,
Visits: 319
|
|
David McKinney (10/11/2010) Shouldn't you have a LEFT JOIN rather than an INNER JOIN?
You're right! In haste, I ran an INNER JOIN so that I could just see the compared rows, but in hindsight, I probably should have kept my base table pure and ran a LEFT JOIN instead. This at least would have allowed me to keep my table counts the same as well as singling out the last row in each partitioned set.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 6:01 PM
Points: 9,
Visits: 319
|
|
ta.bu.shi.da.yu (10/11/2010) If I read this correctly, you just implemented the LAG(...) Over(...) analytic function.
Cool, I didn't even know this existed. But it looks like it's only available in Oracle databases. Microsoft, please bring this over!
However, I'm interested... if you do this on a large dataset, what does the execution plan look like?
Let me try to get my execution plan and I'll get back to you. I do remember that our initial process ran painfully slow and we had just 45K rows. It ran for something like 45 seconds (almost 1 sec/1K rows) using a scalar function. This updated process now takes less than one second to complete.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Yesterday @ 9:04 AM
Points: 16,
Visits: 107
|
|
Real World Example: Wage and Hour Class Action Lawsuits. I am always working with dates on employment cases and many times the individual has many start and end dates. Part of the scrubbing process is to check for date overlaps or gaps. This is a good start to check those types of things.
Thanks for the post! :)
|
|
|
|