Suppose I have this data:
Employee Task IsCurrent
-------- ---- ---------
Jeff 1 Yes
Jeff 2 No
Jane 1 No
Jane 2 Yes
Jane 3 No
Jane 4 No
Jake 1 Yes
Employees have some number of tasks, and one of them will be current. The task number indicates an ordering -- they perform tasks in order, looping back to the beginning when they're done with the last one. I'd like a query to see the next three tasks. I'd like this result set:
Employee CurrentTask NextTask NextTask2
-------- ----------- -------- ---------
Jeff 1 2 1
Jane 2 3 4
Jake 1 1 1
Is this possible? I'm using SQL 2005
UPDATE: Sorry, I didn't make clear that the task numbers aren't necessarily sequental -- i.e. Mike might actually have tasks 10, 23, and 223. So I can't just join looking for the next sequential task number.