select t.* from t,(select a,b,c from t group by a,b,c having count(*)>1) a where t.a=a.a and t.b=a.b and t.c=a.c
谢谢楼上两位, 我可能把意思说错了,是这样的,是要在表中挑出A,B,C组合值相等的记录,而不是A=B=C 字段 A B C D E 值 1 1 4 2 3 2 2 3 1 2 1 1 4 3 4 3 1 1 6 7 1 1 4 5 8 2 2 3 7 9 4 5 6 5 4 。 挑出记录 字段 A B C D E 值 1 1 4 2 3 2 2 3 1 2 1 1 4 3 4 1 1 4 5 8 2 2 3 7 9
Select distinct T1.* from Table T1 inner join T T2 on T1.A = T2.A and T1.B = T2.b and T1.c = T2.c inner join T T3 on T1.A = T3.A and T1.B = T3.b and T1.c = T3.c
select * from tb where A=B
试试: select t.* from qq t,(select a,b,c from qq group by a,b,c having count(*)>1) a; where t.a+t.b+t.c=a.a+a.b+a.c
--根据 A, B 是什么类型 都转换成字符型进行比较 --建立测试环境 create table test1(A integer, B integer, C integer, D integer, E integer) insert into test1 values(1,1,4,2,3) insert into test1 values(2,2,3,1,2) insert into test1 values(1,1,4,3,4) insert into test1 values(3,1,1,6,7) insert into test1 values(1,1,4,5,8) insert into test1 values(2,2,3,7,9) insert into test1 values(4,5,6,5,4)select distinct * from test1 where (str(A)+ str(B)+str(C)) in (select str(A)+ str(B)+str(C) from test1 group by str(A)+ str(B)+str(C) having(count(str(A)+ str(B)+str(C))) > 1 )drop table test1 --输出结果: -- A B C D E -- 1 1 4 2 3 -- 1 1 4 3 4 -- 1 1 4 5 8 -- 2 2 3 1 2 -- 2 2 3 7 9
where A=B and B=C
where t.a=a.a and t.b=a.b and t.c=a.c
我可能把意思说错了,是这样的,是要在表中挑出A,B,C组合值相等的记录,而不是A=B=C
字段
A B C D E
值 1 1 4 2 3
2 2 3 1 2
1 1 4 3 4
3 1 1 6 7
1 1 4 5 8
2 2 3 7 9
4 5 6 5 4
。
挑出记录
字段
A B C D E
值 1 1 4 2 3
2 2 3 1 2
1 1 4 3 4
1 1 4 5 8
2 2 3 7 9
on T1.A = T2.A and T1.B = T2.b and T1.c = T2.c
inner join T T3
on T1.A = T3.A and T1.B = T3.b and T1.c = T3.c
select t.* from qq t,(select a,b,c from qq group by a,b,c having count(*)>1) a;
where t.a+t.b+t.c=a.a+a.b+a.c
--建立测试环境
create table test1(A integer, B integer, C integer, D integer, E integer)
insert into test1 values(1,1,4,2,3)
insert into test1 values(2,2,3,1,2)
insert into test1 values(1,1,4,3,4)
insert into test1 values(3,1,1,6,7)
insert into test1 values(1,1,4,5,8)
insert into test1 values(2,2,3,7,9)
insert into test1 values(4,5,6,5,4)select distinct * from test1
where (str(A)+ str(B)+str(C))
in (select str(A)+ str(B)+str(C) from test1 group by str(A)+ str(B)+str(C) having(count(str(A)+ str(B)+str(C))) > 1 )drop table test1
--输出结果:
-- A B C D E
-- 1 1 4 2 3
-- 1 1 4 3 4
-- 1 1 4 5 8
-- 2 2 3 1 2
-- 2 2 3 7 9