我这是有一些客户订单的数据,我想查出在一个时间段内的客户订单是不是有重复的,其下重了的,要怎么做?条件也就是把客户的名字一样,并且产品编号也一样的显示出来我做了一个临时表C,把要用的字段全放入其中select * from c where fcustid in (Select fcustid From dbo.SEOrder Where Group by fcustid having count(*)>1) amd (fdate between '2009-08-15' And '2009-08-16')ORDER BY fcustid DESC我现在的问题是如何查出产品编号也一样的订单
也就是把名字相同且产品编号也相同的订单数据显示出来
也就是把名字相同且产品编号也相同的订单数据显示出来
AND TIME ...
?
from tb t
where exists(select 1 from 名字=t.名字 and 产品编号=t.产品编号 and fdate!=t.fdate)
select 客户名称,订单编号 from c group by 客户名称,订单编号 having(count(*)>1)至于怎么处理,就看你的要求了
WHERE EXISTS(SELECT 1 FROM TB WHERE 名字=T.名字 AND 编号=T.编号 AND TIME<>T.TIME)
AND TIME BETWEEN '2009-08-15' And '2009-08-16'
这样应该好点
from tb t
where exists(select 1 fromtn where 名字=t.名字 and 产品编号=t.产品编号 and fdate!=t.fdate)
from dbo.SEOrder x
where exists (Select 1 From dbo.SEOrder
Where fcustid = x.fcustid and fdate between '2009-08-15' And '2009-08-16'
and 产品编号 = x.产品编号 and 订单编号<> x.订单编号
)
and fdate between '2009-08-15' And '2009-08-16'
ORDER BY fcustid DESC
fcation 客户代码和
表Item 客户信息表
fcation 对应为了得到客户的名字并显示
而SEOrder 中的fiterid和表SEOrderEntry中的fiterid对应为了得到产品代码我最后想要的就是查出订单中在一个时间段内下重了的订单并显示出来
也就是说客户名字和产品代码同时相同就说明可以下重了,只要把他显示出来就行
select * from c where fcustid in (Select fcustid From dbo.SEOrder Where Group by fcustid having count(*)>1) amd (fdate between '2009-08-15' And '2009-08-16')ORDER BY fcustid DESC
但是我还要再筛选一下名字相同是其一产品代码也要相同,才是最后结果
where fcustid in (Select fcustid From dbo.SEOrder Where Group by fcustid having count(*)>1) amd (fdate between '2009-08-15' And '2009-08-16')ORDER BY fcustid DESC SELECT * FROM #TT T
WHERE EXISTS(SELECT 1 FROM #TT WHERE 名字=T.名字 AND 编号=T.编号 AND TIME<>T.TIME)那这样吧
刚才我问了一个就是id,col相同的,用这种好像不行
不是count(1)..>1吗?
两个,三个不一样吗?