Tag Archives: CTE

How to Use Values from Previous or Next Rows in a SQL Server Query

I recently came across a problem that required having to perform a calculation in a query that involved a value in the current row and a value in the previous row.  The problem is that SQL queries perform operations on a row-by-row basis; accessing data on different rows at the same time requires the query … Continue reading How to Use Values from Previous or Next Rows in a SQL Server Query