I have a SQL Server table with two columns, startDate and endDate. I need a query that returns the rows such that the startDate of the next row matches the endDate of the current row. For example
startDate - endDate 2011/01/01 - 2011/01/02 2011/01/02 - 2011/01/05 2011/01/05 - 2011/01/13 2011/01/13 - 2011/01/15 ... if there is no start matching previous end then just grab 开发者_如何转开发next startDate... 2011/01/19 - 2011/01/23 2011/01/23 - 2011/01/25select t1.StartDate, t1.EndDate from Dates t1 inner join Dates t2 on t1.EndDate=t2.StartDate
精彩评论