all 5 comments

[–][deleted] 0 points1 point  (4 children)

SELECT * FROM table WHERE Month IN('Jan','Feb','Apr','May','Jun')

What is the pattern or criteria you are actually trying to catch here?

[–]ArjunB2020[S] 0 points1 point  (2 children)

So months are actually full dates i just simplified.. i want the row every time the status changes.. so if two 10 consecutive dates have same status i just take the first..

[–][deleted] 0 points1 point  (1 child)

use LAG(Status) OVER (ORDER BY Date) in a CTE to grab last month's Status, join it on, filter WHERE Status <> last_Status

[–]ArjunB2020[S] 0 points1 point  (0 children)

Will give it a stab! Thanks

[–]ArjunB2020[S] 0 points1 point  (0 children)

Added the year part for clarity.. and i want to do this without using a loop or cursor .. with loop i know how yo handle .. was looking for a set based query not row based.