PL/SQL循环查询语句怎么写?

例如:
select count(distinct(process_id )) as"计数" ,20220801 as "日期"
from jssia_eodap.eodap
where to_char(apply_time, 'yyyymmdd') <= 20220801

输出的结果是 计数 日期
14246 20220801

我想 where to_char(apply_time, 'yyyymmdd') <= 20220801 每次递减一天,然后查出结果。
输出: 计数 日期
14246 20220801
XXXX 20220731
XXXX 20220730
....................................
XXXX 20220101

该怎么写语句?

第1个回答  2022-08-03
select count(distinct(process_id )) as 计数 ,to_char(apply_time, 'yyyymmdd') as 日期
from jssia_eodap.eodap
where to_char(apply_time, 'yyyymmdd') <= '20220801'
group by 日期
order by 日期 desc