oracle中查询一月的时间补0的问题
程序员文章站
2022-09-27 14:35:21
sql语句 select NVL(B.weight, 0),A.time from (SELECT TO_CHAR(TO_DATE(开始时间, 'yyyy-MM-dd') + ROWNUM - 1, 'yyyy-MM-dd') AS time FROM DUAL CONNECT BY ROWNUM ......
sql语句
select nvl(b.weight, 0),a.time from
(select to_char(to_date(开始时间, 'yyyy-mm-dd') + rownum - 1, 'yyyy-mm-dd') as time
from dual
connect by rownum <= trunc(to_date(结束时间, 'yyyy-mm-dd') - to_date(开始时间, 'yyyy-mm-dd')) + 1) a
left join (
自己的业务
) b on a.time = b.time order by a.time desc
实现效果
下一篇: MySQL发展及优化方案(未完待续)