I'm not sure exactly what you're expecting the output to look like. Here's a stab at it. I modified the data you provided so that it would return some results.DECLARE @tv_Transactions TABLE( ID int, CustomerID varchar(25), TransactionDay datetime, Sequence int);INSERT @tv_Transactions (ID, CustomerID, TransactionDay, Sequence)SELECT 1, 'I100000999', '2007-07-23 00:00:00.000', 1 UNION ALLSELECT 2, 'I100000999', '2007-07-25 00:00:00.000', 2 UNION ALLSELECT 3, 'I100000999', '2008-05-17 00:00:00.000', 3 UNION ALLSELECT 4, 'I100000999', '2008-05-25 00:00:00.000', 4 UNION ALLSELECT 5, 'I100000999', '2008-06-01 00:00:00.000', 5 UNION ALLSELECT 6, 'I100000999', '2008-07-04 00:00:00.000', 6 UNION ALLSELECT 7, 'I100000997', '2007-12-02 00:00:00.000', 1 UNION ALLSELECT 8, 'I100000997', '2007-12-11 00:00:00.000', 2;WITH TranDays (ID, CustomerID, TransactionDay, NextID, NextTransactionDay, Days) AS( SELECT a.ID, a.CustomerID, a.TransactionDay, b.id as NextID, b.transactionday as NextTransactionDay, DATEDIFF(dd, a.transactionday, b.transactionday) as Days FROM @tv_Transactions a LEFT JOIN @tv_Transactions b ON a.customerid = b.customerid AND b.transactionday > a.transactionday)SELECT ID, CustomerID, TransactionDay FROM TranDays WHERE Days BETWEEN 1 AND 10UNIONSELECT NextID AS ID, CustomerID, NextTransactionDay AS TransactionDay FROM TranDays WHERE Days BETWEEN 1 AND 10;