只要其中的一条,好办
select top 1 ContractID, ProductName, Spec, Unit, Memo
from Repository
where ContractID IN (select distinct ContractID from Repository
where RecordType = 1 ) and ActionDate between '2003-2-1' and '2003-2-28'
select top 1 ContractID, ProductName, Spec, Unit, Memo
from Repository
where ContractID IN (select distinct ContractID from Repository
where RecordType = 1 ) and ActionDate between '2003-2-1' and '2003-2-28'
不兼容又到此混分 ;)
("`-''-/").___..--''"`-._
`6_ 6 ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' ,'
(il),-'' (li),' ((!.-'
不兼容 的形象大使,欢迎盗版!
where RecordType = 1 and ActionDate between '2003-2-1' and '2003-2-28'select ContractID, ProductName, Spec, Unit, Memo
from #t1
where ID IN (select min(ID) from #t1 group by ContractID)
以前的帖子都是我自己最终找到解决的办法 :-POpenVMS(半知半解) 的第一个办法是不行的。因为同时要检索出所有的不重复记录。
所以,用创建临时表,在从临时表里检索的方法 最终检出了正确的结果