Question : SQL Syntax

I want to delete the max(id) that are dups... if the AcctID field and Code field are the same I need themax(id) deleted only keeping the one for each...Any help would be appreciated

ID                   AcctD           Code
125533284      7723902      301
125533610      7723902      301  Wanna delete
125533285      7723902      302
125533611      7723902      302 Wanna delete
125533286      7723902      305
125533612      7723902      305 Wanna delete

Answer : SQL Syntax

This should do
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
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
Random Solutions  
 
programming4us programming4us