- 关 键 词:
- oracle数据库
select case
when (new_yweek = min(new_yweek)over(partition by mon order by new_yweek)) then
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;查看 http://www.qqread.com/oracle/2008/03/y402000.html
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- 数据库专栏 (5181篇文章)
- 数据库处理专题 (8774篇文章)
- 城域网专题 (7858篇文章)
- 数据库安全技术专题 (13256篇文章)
- 数据库安装与卸载 (10603篇文章)
- Oracle 10g基础应用 (4506篇文章)
- Linux数据库宝典 (13306篇文章)
- 数据库相关文章 (5181篇文章)
- 数据库体系架构 (1102篇文章)
- Oracle语句优化规则汇总(8) (17次浏览)
- Data Guard学习物理standby高级管理 (17次浏览)
- 甲骨文如何解析语义谜题 (13次浏览)
- 一步一步配置Oracle Stream (11次浏览)
- 如何查找运行系统里的“bad sql”语句 (9次浏览)
- 讲解“Oracle”下导出某用户所有表的方法 (8次浏览)
- Oracle语句优化规则汇总(5) (8次浏览)
- Oracle更新操作优化 (8次浏览)
- 实现数据库事务的方法ExecuteSqlTran() (7次浏览)
- Oracle中利用一个表结构拷贝成另外的表 (7次浏览)



