Alright. Brace yourself. I'm using a little bit of a cheating method by using the running total UPDATE method. There are some quirks, so be weary of putting this in production code. The biggest of which is how the table is traversed. a Clustered index should probably be put on the APPROVAL_DAY column to ensure that the dates aren't split. Anyway, here goes.
CREATE TABLE #test
(
ID int,
APPROVAL_DT date,
DAY_DT date,
TRANS_COUNT int,
SALE_AMOUNT int,
DailyTransCount int,
DailySalesTotal int
)
INSERT INTO #test
SELECT 1,'2010-04-22','2010-04-27',2,260,0,0 UNION ALL
SELECT 1,'2010-04-22','2010-04-28', 1,40, 0,0 UNION ALL
SELECT 2,'2010-03-28','2010-04-02', 1,5, 0,0 UNION ALL
SELECT 2,'2010-03-28','2010-04-03', 5,10, 0,0 UNION ALL
SELECT 2,'2010-03-28','2010-04-04', 1,20, 0,0 UNION ALL
SELECT 3,'2010-04-25','2010-05-01', 6,10, 0,0 UNION ALL
SELECT 3,'2010-04-25','2010-05-02', 4,10, 0,0 UNION ALL
SELECT 4,'2010-06-01','2010-06-07', 1,5, 0,0
DECLARE @PreviousDay date; SET @PreviousDay = '29991231'
DECLARE @DailyTransCount int; SET @DailyTransCount = 0
DECLARE @DailySalesTotal int; SET @DailySalesTotal = 0
DECLARE @Group int; SET @Group = 0
UPDATE #test
SET DailyTransCount = 0,
DailySalesTotal = 0
UPDATE #test
SET @DailyTransCount = DailyTransCount = CASE WHEN APPROVAL_DT = @PreviousDay THEN @DailyTransCount + Trans_Count ELSE Trans_Count END,
@DailySalesTotal = DailySalesTotal = CASE WHEN APPROVAL_DT = @PreviousDay THEN @DailySalesTotal + SALE_AMOUNT ELSE SALE_AMOUNT END,
@PreviousDay = APPROVAL_DT
SELECT Y.ID, X.APPROVAL_DT, X.DAY_DT FROM
(SELECT DISTINCT(ID) FROM #test T) Y
LEFT JOIN ( SELECT ID, APPROVAL_DT, MIN(DAY_DT) AS DAY_DT FROM #test
WHERE DailyTransCount >= 10 OR DailySalesTotal >= 25
GROUP BY ID, APPROVAL_DT ) X ON X.ID = Y.ID
I should explain a few things: I have created two more columns on the end of my table. You'll need to put this into a temp table (or permanent table) to push out the totals into. After I push all of the totals into the columns, it's just a select to retrieve the results. There is more information on this technique here. Note that this solution is FAST, but has a bit of an unsafe-ness to it.