Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Get range of on the basis of Value grouping

$
0
0
Hi ,I have below table CREATE TABLE #tmp(Date DATE, Amount Int)INSERT #tmp ( Date, Amount )SELECT '2016-10-01',2700UNIONSELECT '2016-10-02',2700UNIONSELECT '2016-10-03',2700UNIONSELECT '2016-10-04',3000UNIONSELECT '2016-10-05',3000UNIONSELECT '2016-10-06',2700UNIONSELECT '2016-10-07',4700UNIONSELECT '2016-10-08',4700UNIONSELECT '2016-10-09',4700UNIONSELECT '2016-10-10',5700UNIONSELECT '2016-10-11',5700UNIONSELECT '2016-10-12',2700UNIONSELECT '2016-10-13',2700UNIONSELECT '2016-10-14',3000And I want output like :/*Expected OUTPUT :StartDAte End Date Amount2016-10-01 2016-10-03 27002016-10-04 2016-10-05 30002016-10-06 2016-10-06 27002016-10-07 2016-10-09 47002016-10-10 2016-10-11 57002016-10-12 2016-10-13 27002016-10-14 2016-10-14 3000*/Please help to solve it.Thanks

Viewing all articles
Browse latest Browse all 3145

Trending Articles