设为首页 加入收藏

TOP

oralcesql创建指定时间段内的日历信息
2015-07-24 10:35:46 来源: 作者: 【 】 浏览:1
Tags:oralcesql 创建 指定 时间段 日历 信息

创建 开始时间是2010 截止时间是2100的日历表数据。

create table temp_calendar as select

   min(to_char(day, 'yyyymm')) month,
   to_char(min(decode(weekday, 1, day)) ,'dd') w_7,
   to_char(min(decode(weekday, 2, day)),'dd') w_1,
   to_char(min(decode(weekday, 3, day)),'dd') w_2,
   to_char(min(decode(weekday, 4, day)),'dd') w_3,
   to_char(min(decode(weekday, 5, day)),'dd') w_4,
   to_char(min(decode(weekday, 6, day)),'dd') w_5,
   to_char(min(decode(weekday, 7, day)),'dd') w_6
  from (select trunc(day,'yyyy') year,
day,
         month,
         decode(sign(rn - weekday), 1, week + 1, week) week,
         weekday,
         rn
       from (select day,
             to_char(day, 'mm') month,
             to_char(day, 'w') week,
             to_char(day, 'd') weekday,
             row_number() over(partition by to_char(day, 'mm'), to_char(day, 'w') order by day) rn
           from (select trunc(to_date('2008','yyyy'), 'yyyy') + level - 1 day
               from dual
              connect by rownum <= trunc(to_date('2101','yyyy'),'yyyy')-trunc(to_date('2008','yyyy'),'yyyy')))) a
  group by a.year,a.month, a.week
  order by a.year,a.month, a.week;
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle核心技术笔记(该书读得不.. 下一篇Oracleredo复杂度--oracle核心技..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·请问c语言刚入门,该 (2025-12-26 10:21:04)
·python 编程怎么定义 (2025-12-26 10:21:01)
·09-指 针 (一)-c语言 (2025-12-26 10:20:58)
·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)