首页 > 数据库技术 > 详细

oracle 当月日历的sql

时间:2016-07-06 13:20:47      阅读:350      评论:0      收藏:0      [点我收藏+]
select max(sun) sun,
       max(mon) mon,
       max(tue) tue,
       max(wed) wed,
       max(thu) thu,
       max(fri) fri,
       max(sat) sat
  from (select decode(d, 1, dd) sun,
               decode(d, 2, dd) mon,
               decode(d, 3, dd) tue,
               decode(d, 4, dd) wed,
               decode(d, 5, dd) thu,
               decode(d, 6, dd) fri,
               decode(d, 7, dd) sat,
               iw
          from (select to_char(dates, d) d,
                       to_char(dates, dd) dd,
                       to_char(dates + 1, iw) iw,
                       dates
                  from (select trunc(to_Date(&date, yyyy-mm-dd), mm) +
                               level - 1 dates
                          from dual
                        connect by level <= to_char(last_day(to_Date(&date,
                                                                     yyyymmdd)),
                                                    dd))))
 group by iw
 order by iw

 

oracle 当月日历的sql

原文:http://www.cnblogs.com/wolil/p/5646420.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!