You should be able to do a left join on to the table itself and calculate this. Since there is no sequential number, you would need to generate one - which is what the CTE in the query below does.;WITH cte AS( SELECT *,ROW_NUMBER() OVER (PARTITION BY col1 ORDER BY col3) AS RN FROM YourTable)SELECT a.col1, a.col3, a.col3, COALESCE(DATEDIFF(dd,b.col3,a.col3),0) AS differenceColFROM cte a LEFT JOIN cte b ON a.RN = b.RN+1 AND a.col1 = b.col1