带你轻松接触Oracle数据库的日历


select case
          when (new_yweek = min(new_yweek)over(partition by mon order by new_yweek)) then


            mon_name
          else
            null
        end as month,
        new_yweek as yweek,
        row_number() over(partition by mon order by new_yweek) as mweek,
        sum(decode(wday, '1', mday, null)) as sun,
        sum(decode(wday, '2', mday, null)) as mon,
        sum(decode(wday, '3', mday, null)) as tue,
        sum(decode(wday, '4', mday, null)) as wed,
        sum(decode(wday, '5', mday, null)) as thu,
        sum(decode(wday, '6', mday, null)) as fri,
        sum(decode(wday, '7', mday, null)) as sat
    from (select dayofyear as everyday,
                to_char(dayofyear, 'mm') as mon,
                to_char(dayofyear, 'Month') as mon_name,
                to_char(dayofyear, 'w') as mweek,
                to_char(dayofyear, 'ww') as yweek,
                case
                  when (to_char(to_date(&year || '0101', 'yyyymmdd'), 'd') > '1') and
                        (to_char(dayofyear, 'd') <
                        to_char(to_date(&year || '0101', 'yyyymmdd'), 'd')) then
                    to_char(to_char(dayofyear, 'ww') + 1, 'fm00')
                  else
                    to_char(dayofyear, 'ww')
                end as new_yweek,
                to_char(dayofyear, 'd') as wday,
                to_char(dayofyear, 'dd') as mday
            from (select to_date(&year || '0101', 'yyyymmdd') + level - 1 as dayofyear
                    from dual
                  connect by level <= to_char(to_date(&year || '1231', 'yyyymmdd'),'ddd')
                )
        )
  group by mon, mon_name, new_yweek;

本文作者:



相关阅读:
解决MySQL启动时万恶的的“1067”错误
PHP教程:PHP开发网站代码编写规范
BSD家族大观 --2. OpenBSD
JSP/Servlet/JSF:自定义标签
JS教程:浅谈ECMAScript自动插入分号
asp.net保存远程图片的代码
CSS改变选择网页文字背景色
感受Win 2003 SP1安全配置向导功能
用PHP和ACCESS写聊天室(七)
学习CSS需要知道的CSS基础知识
帝国网站管理系统之安全设置最优化分享
IE与Firefox下javascript getyear年份的兼容性写法
SQL Server视图管理中需要遵守的四个限制条件
Linux之父Linus Torvalds谈论各发行套件
快速导航

Copyright © 2016 phpStudy |