表T1字段 A 字段Baa bb
af ff
rt we
ff gg
ff gg
--------------------------
要显示
ff gg select a,b from t1 group by a,b having count(*)>1 这样可以查出来
用表连接的方式怎么查?
af ff
rt we
ff gg
ff gg
--------------------------
要显示
ff gg select a,b from t1 group by a,b having count(*)>1 这样可以查出来
用表连接的方式怎么查?
(select 1 from t1 b where b.rowid<>a.rowid and b.a=a.a and b.b=a.b)
要去重复加上distinct,效率明显低了些
这种方法就很好,为什么还要用表连接呢?
from t1 a inner join t1 b
on a.a = b.a
and a.b=b.b
from
(
select t.* ,row_number() over(partition by t.字段 A,t.字段B order by t.字段A desc) rn from t1 t
) a where a.rn=2
或者
select d.*
from t1 d,
(
select max(rowid)
from t1 a, t1 b
where a.字段 A=b.字段 A
and b.字段 B=b.字段 B
) c where d.rowid=c.rowid