Select MIN(t.id) AS id, t.account_id,t.rev_code
INTO #tmp
from
transactions t
inner join accounts am on t.account_id = am.account_id
inner join downloads d on d.download_id = am.download_id
where d.download_id =1773
GROUP BY t.account_id,t.rev_code
order by t.account_id,t.rev_code
go
DELETE FROM TRANSACTIONS WHERE id IN (SELECT id FROM #tmp)
GO
|