日期:2014-05-16  浏览次数:20379 次

oracle日历

select max(decode(to_char(dt, 'day'), '星期日', to_char(dt, 'dd'))) "星期日",
       max(decode(to_char(dt, 'day'), '星期一', to_char(dt, 'dd'))) "星期一",
       max(decode(to_char(dt, 'day'), '星期二', to_char(dt, 'dd'))) "星期二",
       max(decode(to_char(dt, 'day'), '星期三', to_char(dt, 'dd'))) "星期三",
       max(decode(to_char(dt, 'day'), '星期四', to_char(dt, 'dd'))) "星期四",
       max(decode(to_char(dt, 'day'), '星期五', to_char(dt, 'dd'))) "星期五",
       max(decode(to_char(dt, 'day'), '星期六', to_char(dt, 'dd'))) "星期六"
  from (select to_char(dt, 'd') - row_number() over(order by dt) gcol, dt
          from (select trunc(to_date('2010-12-18', 'yyyy-mm-dd'), 'mm') +
                       level - 1 dt
                  from dual
                connect by level <= to_char(last_day(to_date('2010-12-18',
                                                             'yyyy-mm-dd')),
                                            'dd')))
 group by gcol
 order by abs(gcol)
?