公司项目里有个需求是生成一个X轴固定长度的图表,数据库用的oracle,要求效果如下:
所以就需要动态补齐年月信息,补全sql语句如下:
select dat,'毛利'as type1,0 as unml from ( SELECT to_char(add_months(sysdate,ROWNUM),'yyyy-mm') dat FROM dual CONNECT BY ROWNUM <= months_between(add_months(trunc(sysdate,'YYYY'),12),sysdate) )
每月未发生日期查询语句:
SELECT TO_CHAR( sysdate + ROWNUM,'YYYY/MM/DD' ) FROM DUAL CONNECT BY ROWNUM <=( last_day(sysdate) - sysdate );原文链接:https://www.f2er.com/oracle/208346.html