ID 缴费号码 缴费金额
1 139139134 60
2 139139139 50
3 139139134 40
4 139139134 50
5 139139139 70
6 139139134 80
现在需要SQL找出 可能不止2次
3 139139134 40
4 139139134 50
1 139139134 60
2 139139139 50
3 139139134 40
4 139139134 50
5 139139139 70
6 139139134 80
现在需要SQL找出 可能不止2次
3 139139134 40
4 139139134 50
with aa as
(
select id,no,fee,
count(1) over (
patition by no,order by id
rows between unbounded preceding and unbounded following
) pay_times
from t
)
select *
from aa
where pay_times>1
(
select t.id,t.no,t.fee,
lag(no,1,no) over(order by id) last_no,
lead(no,1,no) over(order by id) next_no
from t
)
select * from aa where no=last_no or no=next_no
wiht aa as
(
select t.id,t.no,t.fee,
lag(no,1,null) over(order by id) last_no,
lead(no,1,null) over(order by id) next_no
from t
)
select * from aa where no=last_no or no=next_no
取下一行
plsql特有的