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

How to combine several records into one

$
0
0

Hi All,

I have the following records

MemberId,StartDate, EndDate, Status

1,2013-1-1, 2013-5-1 , Close

1,2013-5-11, 2013-6-1, Close

1,2013-6-23, 2013-9-1, Open

I want combing all the records into one, the logic is if the records MemberId is the same and the second order's Startdate - the first order's Enddate is less than 30, then Combine them and use the last records status.

So for the above example, that 3 records will be combined into one.

MemberId, StartDate, EndDate, Status

1,2013-1-1,2013-9-1, Open

Can we finish it?

Thanks.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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