Many T-SQL query problems involve matching rows based on their location in
a sequence—typically, a temporal sequence. A classic example of such a
problem is matching each customer’s current and preceding orders to compare
measures and analyze trends. There are several possible approaches to a solution.
Here, I compare the performance and I/O costs of a cursor solution and two set-based
solutions for matching current and preceding rows and share some query optimizer
tips along the way.
...This article is for paid Professional Members only.
Already a Professional Member? Please log in now: