我也接着优化下:
select t.id, sum(t.sale_num)
from (select r.id,
r.sale_date,
min(r.sale_date) over(partition by r.id) as min_date,
r.sale_num
from web_clm_rule r) t
where t.sale_date between t.min_date and t.min_date + 90
group by t.id
having sum(t.sale_num) <= 10