I have this table “insurance” in SQL Server 2008
insuranceId StartDate EndDate CarID
1 1-jan-2010 1-Jan-2011 1
2 2-Jan-2011 2-Jan-2012 1
3 1-Jan-2012 1-Jan-2012 2
I need to write Query Return :
cars were insurance by two consecutive
This database For Insurance Company I need to get the Car that have two consecutive Insurance
in the other word get the car which Enddate in the record = (startdate + 1) in The other record for the car
for this table i need to get the carId = 1 because
EndDate in Firstrecord = 1-Jan-2011 and the StartDate in second record = 2-Jan-2011
As I understand it, this gives what you want: