table a:
列名: a b c d
1 2 3 4
2 3 4 5
3 4 5 6
1 7 8 9
2 4 5 6
取table a 列名a 数值有重复的行
结果如下:
a b c d
1 2 3 4
2 3 4 5
1 7 8 9
2 4 5 6
sql 语句怎么写
Select a,b,c,d from tableA
where a in (Select a, count(*) AS IDCount from tableA group by a having count(*)>1)
-- #temp 示例创建的临时表
select * from #temp
where a in
(
select a from #temp group by a having COUNT(a)>1 --判断表中a字段(列)中出现重复行的值
)
从效率来讲,如果使用in语句,大数据量的话,就会导致效率降低