【发布时间】:2020-02-17 08:21:06
【问题描述】:
我需要根据截至 2 月的财政年度调整日期范围。
因此,在运行 2020 年 1 月报告时,需要计算从 2017/12(2018 年 2 月)到 2019/11(2020 年 1 月)的 24 个月窗口。如何获得以下动态计算?
define v_report_month = 1
define v_report_year = 2020
define v_start_year = if &v_report_month > 1 then &v_report_year - 2 else &v_report_year - 3 end if
define v_start_monthno = if &v_report_month > 1 then &v_report_month - 1 else &v_report_month + 11 end if
define v_end_year = if v_report_monthno > 2 then v_report_year else v_report_year - 1 end if
define v_end_monthno = if v_report_monthno > 2 then v_report_month - 2 else v_report_monthno + 10 end if
当我尝试运行以下命令时,只得到--“ORA-00933:SQL 命令未正确结束”
select
&v_start_year as y
,&v_start_monthno as m
from dual;
【问题讨论】:
标签: sql oracle if-statement variables oracle-sqldeveloper