通常我们查重是这么写的,按照某个条件筛选重复
select * from dbo.T_ECert a
where (a.ECERTID) in (select ECERTID from T_ECert group by ECERTID+idcard having count(*) > 1)
但是如果需要有多个条件怎么办呢?
oracle可以这样
select * from dbo.T_ECert a
where (a.ECERTID,a.idcard) in (select a.ECERTID,a.idcard from T_ECert group by ECERTID,idcard having count(*) > 1)
这样可以解决多条件查询,但是sql server 2008就不可以,但我想到一个办法可以这样
select * from dbo.T_ECert a
where (a.ECERTID+a.idcard) in (select a.ECERTID+a.idcard from T_ECert group by ECERTID+idcard having count(*) > 1)
将多个条件相加,这样可以合并为一个列,不同数据拼接出来的数据肯定不同,所以可以解决多条件筛重
时间: 2024-11-05 15:41:40