我有一個表table1,它有以下列。group by clause
假設有像localamount這樣的記錄是20,000,30000,50000,100000然後根據我的情況,我必須根據該組的站點id刪除記錄,直到id,transid,shift id where localamount超過10,000 ...其餘記錄可用?
我的目標是從這個表中,當地量是根據網站ID超過10,0000刪除行,直到ID,TRANSID,移位ID
SiteId varchar(10),
TillId tinyint,
ShiftId int,
TransId int,
TranDate datetime,
SettlementType varchar(5),
CreditCardNumber varchar(25),
ProductTypeCode varchar(10),
NewProductTypeCode varchar(10),
TransactionType int,
ForeignAmount money,
LocalAmount money,
ProductCode varchar(10)
澄清:你是說你想如果具有(SiteId,TillId,TransId,ShiftId)的所有行的LocalAmount字段的總數超過100,000,則刪除具有特定(SiteId,TillId,TransId,ShiftId)的所有記錄? – ngroot 2010-09-08 15:13:28