或:select a.*,b.重复数 from 表 a join (select col3,count(*) 重复数 from 表 group by col3) b on a.col3=b.col3
要是我仅需要显示Col3重复大于1的如何做?
select * ,(select count(*) from 表 where col3 = a.col3) 重复数 from 表 a where (select count(*) from 表 where col3=tem.col3) > 1
select * ,(select count(*) from 表 where col3 = a.col3) 重复数 from 表 a where (select count(*) from 表 where col3 = a.col3) >1
select a.*,b.重复数 from 表 a join (select col3,count(*) 重复数 from 表 group by col3) b on a.col3=b.col3 where b.重复数>1
或: select a.*,b.重复数 from 表 a join (select col3,count(*) 重复数 from 表 group by col3 having count(*)>1) b on a.col3=b.col3 where b.重复数>1 或: select *,(select count(*) from 表 where col3=tem.col3) 重复数 from 表 tem where (select count(*) from 表 where col3=tem.col3)>1
select * ,(select count(*) from 表 where col3 = a.col3) as 重复数 from 表 a where 重复数>1
--显示统计结果: select *,重复数=(select sum(1) from table1 where col3=a.col3) from table1 a--仅显示重复次数大于1的记录 select * from( select *,重复数=(select sum(1) from table1 where col3=a.col3) from table1 a ) where 重复数>1
,(select count(*) from 表 where col3 = a.col3) 重复数
from 表 a
where (select count(*) from 表 where col3=tem.col3) > 1
,(select count(*) from 表 where col3 = a.col3) 重复数
from 表 a
where (select count(*) from 表 where col3 = a.col3) >1
select a.*,b.重复数 from 表 a join (select col3,count(*) 重复数 from 表 group by col3 having count(*)>1) b on a.col3=b.col3 where b.重复数>1
或:
select *,(select count(*) from 表 where col3=tem.col3) 重复数 from 表 tem where (select count(*) from 表 where col3=tem.col3)>1
,(select count(*) from 表 where col3 = a.col3) as 重复数
from 表 a
where 重复数>1
select *,重复数=(select sum(1) from table1 where col3=a.col3)
from table1 a--仅显示重复次数大于1的记录
select * from(
select *,重复数=(select sum(1) from table1 where col3=a.col3)
from table1 a
) where 重复数>1