jeudi 9 avril 2015

I want to update multiple date field rows into one single row

I have a table as shown below. Here is a sample table with multiple records. In Jan, March, April and then in June there are 3 records.



PeriodID Period_From Period_To Member FirstName LastName CodeID
1 1/16/2014 1/28/2014 151 Robert Flow TWIT
2 3/7/2014 3/20/2014 151 Robert Flow TWIT
3 4/3/2014 4/10/2014 151 Robert Flow TWIT
4 6/2/2014 6/4/2014 151 Robert Flow TWIT
5 6/6/2014 6/8/2014 151 Robert Flow TWIT
6 6/13/2014 6/19/2014 151 Robert Flow TWIT


So for Jan, March and April Date-Periods we treat as separate Periods/records. and for June I need only 2 records if the 'Period_From' is > 2 days of Previous record (i.e from 'Period_To') then we consider as separate record else take the Period_From from 1st record and Period_To from 2nd record and update in 1 single row.


I want solutions as below:



PeriodID Period_From Period_To Member FirstName LastName CodeID
1 1/16/2014 1/28/2014 151 Robert Flow TWIT
2 3/7/2014 3/20/2014 151 Robert Flow TWIT
3 4/3/2014 4/10/2014 151 Robert Flow TWIT
4 6/2/2014 6/8/2014 151 Robert Flow TWIT
6 6/13/2014 6/19/2014 151 Robert Flow TWIT

Aucun commentaire:

Enregistrer un commentaire