WADRIAN68 (10/2/2015)
Hi WayneThat's beautiful, Thank you!
I've also learnt something as I had no idea the LAG function existed. I've replicated the concept into my actual scenario and am achieving exactly what I wanted.
Thank you very much for the solution.
Regards
Adrian
Adrian,
Glad it's working for you.
If you have questions about how LAG works, check out Books Online or grab a copy of my book (see link below in my signature).
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes