oracle 查出某月周末,oracle查询某月第某周 这一周的开始日期和结束日期

满意答案

dcebd7a0de6265b6ccae5ead692f1eab.png

音乐书海102

2017.12.14

dcebd7a0de6265b6ccae5ead692f1eab.png

采纳率:56%    等级:9

已帮助:315人

with t1 as (select level id, '201507' || lpad(level, 2, '0') col from dual connect by level < 32),t2 as (select 0 id, null, to_char(trunc(to_date(col, 'yyyymmdd'), 'month'), 'yyyymmdd') end_dt from t1 where rownum = 1 union all select 32, null, '-' || to_char(last_day(trunc(to_date(col, 'yyyymmdd'), 'month')), 'yyyymmdd') from t1 where rownum = 1 union all select id, to_date(col, 'yyyymmdd'), decode(to_number(to_char(to_date(col, 'yyyymmdd'), 'D')) - 1, 0, '-' || col, 1, col) from t1 where col <= to_char(last_day(trunc(to_date(substr(col, 1, 6) || '01', 'yyyymmdd'), 'month')), 'yyyymmdd')),t3 as (select id, decode(instr(lag(end_dt, 1) over(order by id), '-'), 1, null, lag(end_dt, 1) over(order by id)) start_dt, end_dt from t2 where end_dt is not null order by id)select '第' || rownum || '周:' des, start_dt || end_dt from t3 where start_dt is not null order by id;

00分享举报

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值