insert into detail(ContractNo,CustCode,Amount) values('ds20111230','ws001',1000) insert into detail(ContractNo,CustCode,Amount) values('ds20111230','ws002',1300) insert into detail(ContractNo,CustCode,Amount) values('ds20111231','ws003',1000) insert into detail(ContractNo,CustCode,Amount) values('ds20111232','ws002',1000) insert into detail(ContractNo,CustCode,Amount) values('ds20111233','ws002',1000) insert into detail(ContractNo,CustCode,Amount) values('ds20111234','ws001',1000) insert into detail(ContractNo,CustCode,Amount) values('ds20111235','ws001',1000)
select *
from Detail t
where exists (select 1 from Detail where CustCode=t.CustCode and Amount=t.Amount and ContractNo='ds20111230')
------解决方案--------------------