Friday, November 1, 2013

selecting consecutive records from a table based on a column value

mnmhema,


Can you try by increasing the recursion limit ?




select t.* from #temp2 t,
(
select top 1 cola as cola
from cte where level=4 and colc='free'--to get the 1st rec thts free
order by cola
) tt
where t.cola between tt.cola-3 and tt.cola
option (maxrecursion 0)--setting the maxrecursion limit as unlimited for this query

Thanks,


Jayakumaur


<Please mark as 'answered' if this answers your query>


<Please mark as 'helpful' if this was helpful to your query>





No comments:

Post a Comment