求一条sql语句
查处表tab中几个字段相同的记录来。
假设有5个字段a,b,c,d,e
要求查出a,b,c三个字段有两条以上记录相同的全部记录。
问题点数:40、回复次数:7Top
1 楼letsflytogether(伍子)回复于 2003-12-03 11:08:33 得分 5
select * from tab group by a having count(*)>1
union
select * from tab group by b having count(*)>1
union
select * from tab group by c having count(*)>1Top
2 楼dlpseeyou(豆子)回复于 2003-12-03 11:15:37 得分 0
select max(a) a ,max(b) b ,max(c) c from tab group by zs,kyrq,qymc having count(*)>1
我试过了Top
3 楼Rotaxe(程序员)回复于 2003-12-03 11:16:14 得分 5
select * from tab group by a,b,c having count(1)>1Top
4 楼dlpseeyou(豆子)回复于 2003-12-03 11:16:38 得分 5
对不起,改了几个字母:现在好了。
select max(kyrq) kyrq ,max(qymc) qymc from test1 group by a,b,c having count(*)>1Top
5 楼victorycyz(--)回复于 2003-12-03 11:19:30 得分 10
select * from tab join (select a,b,c from tab group by a,b,c having count(*)>1) T on tab.a=t.a and tab.b=t.b and tab.c=t.cTop
6 楼dlpseeyou(豆子)回复于 2003-12-03 11:21:58 得分 5
select max(a) a,max(b) b,max(c) c from 表名 group by a,b,c having count(*)>1Top
7 楼zhaokeke2004(男人·海洋)回复于 2003-12-03 15:49:16 得分 10
select 你要的列 from tab group by a,b,c having count(*)>1
Top




