Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Sql Server - group by based on change in row values

$
0
0

Hi,

I have a scenario. I need to make a group by based on value change in rows. Eg - two columns date and value.

Jan 1 -  15

Jan 2 -  15

....

Jan 5 - 10

......

Jan 8 - 15

If I group by value I will get Min date as Jan 1 and Max date as Jan 8 but I should have output as below.

Jan 1 - Jan 4 - 15

Jan 5 - Jan 7 - 10

Jan 7- Jan 15- 15. Is there any quick logic for this with query itself (like rank)  without any looping since I cannot afford cost for query. I have to make this only in SP.

Thanks,

Paddu


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>