id apply_id
1 1
2 1
3 1
4 2
5 2
6 3
7 3
8 3
取出
id apply_id
3 1
5 2
8 3
select alx_a.id
from
(select id,apply_id,rownum rid from 表) alx_a,
(select id,apply_id,rownum rid from 表) alx_b
where alx_a.apply_id = alx_b.apply_id and alx_a.id <= alx_b.id
group by alx_a.id,alx_a.apply_id
having count(*) = 1
如果id值有相同的,则该语句会把这些记录过滤掉。原因是<=这个运算符会造成count(*)的值不为1
回复删除