码迷,mamicode.com
首页 > 数据库 > 详细

oracle 当月日历的sql

时间:2016-07-06 13:21:50      阅读:400      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!