1.表结构如下:
销售业绩表dw_pay_infos
字段 字段释义
sell_id 销售id
sell_name 销售姓名
student_pay_time 销售签单学生付费时间
student_pay_money 销售签单学生付费金额,单位元
oracle代码如下:
select * from (
select sell_id,
sell_name,
year_x,
money,
cou_y,
lag(cou_y) over (partition by sell_id order by year_x) as before_x,
lead(cou_y) over (partition by sell_id order by year_x) as after_x
from(
select sell_id,
sell_name,
year_x,
money,
count(*) over(partition by sell_id order by year_x range between 1 preceding and 1 following) as cou_y
from(
select sell_id,
sell_name,
extract (year from student_pay_time) as year_x,
sum(student_pay_money) as money
from dw_pay_infos
group by sell_id,
extract (year from student_pay_time)
sum(student_pay_money) > 100000
order by sell_id,year_x
)
)
)
where cou_y >= 3
or before_x >= 3
or after_x >= 3