1:
第一种:
SELECT TO_CHAR(ADD_MONTHS(TO_DATE(CONCAT('2022','0101'), 'YYYYMMDD'), LEVEL - 1), 'mm') || '月' AS month
FROM DUAL
CONNECT BY LEVEL <= 12
第二种:
SELECT TO_CHAR(ADD_MONTHS(DATE '20220101', LEVEL - 1), 'mm') || '月' AS month
FROM DUAL
CONNECT BY LEVEL <= 12
执行结果:
2:个人使用
SELECT A.month AS 每年月份 ,nvl(B.目标值,0) AS 目标值, NVL(B.完成率,0) AS 完成率 from(
SELECT TO_CHAR(ADD_MONTHS(TO_DATE(CONCAT('2022','0101'), 'YYYYMMDD'), LEVEL - 1), 'mm') || '月' AS month
FROM DUAL
CONNECT BY LEVEL <= 12) A
left join
(SELECT
NVL((round(SUBSTR(STAT_TIME,5,6)/12* 100,2)),0) AS 目标值,
NVL(REFORM_TASK_COM_RATE,0) AS 完成率,
SUBSTR(STAT_TIME,5,6)|| '月' AS 每年月份
FROM BRAIN.DM_ZHGL_REFORM_TASK_INFO
WHERE SUBSTR(STAT_TIME,1,4) = 2022)
B
ON A.month = B.每年月份
结果:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/121351.html