请问这段数据集筛选应该怎么写,年份是参数,需要取预算值,如果选的年份小于当前年份,substr(ym,5,8)='年度目标',否则的话就是substr(ym,1,4)=当前年份 and substr(ym,6,2)<=当前月份,ym字段数据形式是2021年度目标和2021-01这种
select substr(ym,1,4) year,sum(value) ys from FR_FIN_INPUT_LRB
WHERE substr(ym,1,4)='${year}' and substr(ym,5,1)='-'
and ym<=(select to_char(sysdate,'yyyy-MM') from dual)
and project_id='0101'
and company_id='W10'
group by substr(ym,1,4)