首页
论坛
门户
空间
手机版
下载
IXPUB
插件
收藏
设置
注册
登录
商店
搜索
培训
Blog
归档
退出
ITPUB专业网站群:
微软技术社区
移动开发社区
企业内容管理社区
ITPUB论坛
»
Oracle开发
» sql实现当月日历
Itpub-oracle培训最实用的技能培训
itpub站庆征文“我在ITPUB的日子”
windows嵌入式有奖征文-数码相机等你拿
线上参会思科虚拟体验
本版相关圈子 欢迎加入
Oracle ACE
Oracle中间件
Oracle OCP认证
华南DBA圈子
Oracle选件技术
‹‹ 上一主题
|
下一主题 ››
13
1/2
1
2
››
投票
交易
悬赏
活动
评价
|
打印
|
推荐
|
订阅
|
收藏
标题: sql实现当月日历
wngsheng
中级会员
精华贴数 0
个人空间
0
技术积分 479 (4529)
社区积分 965 (1134)
注册日期 2001-12-6
论坛徽章:5
#1
使用道具
发表于 2007-7-9 16:53
sql实现当月日历
select max(su) su,max(mo) mo,max(tu) tu,max(we) we,max(th) th,max(fr) fr,max(sa) sa from
(select case when d=1 then dd end su,
case when d=2 then dd end mo,
case when d=3 then dd end tu,
case when d=4 then dd end we,
case when d=5 then dd end th,
case when d=6 then dd end fr,
case when d=7 then dd end sa,
d,w,iw
from(
select dates,to_char(dates,'dd') dd,to_number(to_char(dates,'d')) d,to_char(dates,'w') w,to_char(dates+1,'iw') iw from
(select trunc(sysdate,'month')+level-1 dates from dual
connect by rownum<last_day(sysdate)-trunc(sysdate,'month')
)
)
)
group by iw
order by iw;
环境:oracle 10g
__________________
我为人人,人人为我,天下大公。
只看该作者
junsansi
无名扫把
来自 bj
精华贴数 10
个人空间
10664
技术积分 11632 (117)
社区积分 3590 (458)
注册日期 2006-7-17
论坛徽章:201
#2
使用道具
发表于 2007-7-9 17:02
Re: sql实现当月日历
QUOTE:
最初由 wngsheng 发布
select max(su) su,max(mo) mo,max(tu) tu,max(we) we,max(th) th,max(fr) fr,max(sa) sa from
(select case when d=1 then dd end su,
case when d=2 then dd end mo,
case when d=3 then dd end tu,
case when d=4 then dd end we,
case when d=5 then dd end th,
case when d=6 then dd end fr,
case when d=7 then dd end sa,
d,w,iw
from(
select dates,to_char(dates,'dd') dd,to_number(to_char(dates,'d')) d,to_char(dates,'w') w,to_char(dates+1,'iw') iw from
(select trunc(sysdate,'month')+level-1 dates from dual
connect by rownum<last_day(sysdate)-trunc(sysdate,'month')
)
)
)
group by iw
order by iw;
环境:oracle 10g
不错,不过w和iw留1个即可
__________________
=======================================
我爱我佳
扫地不过是我表面上的工作,我真正的身份其实是无名老僧------------------手里那根扫把~~~~
只看该作者
hanjs
高级会员
来自 沈阳
精华贴数 1
个人空间
0
技术积分 10326 (137)
社区积分 52 (5473)
注册日期 2006-7-30
论坛徽章:18
#3
使用道具
发表于 2007-7-9 17:03
不错,不过都有查出一年的了!
__________________
Database Concepts
Database Performance Tuning Guide and Reference
只看该作者
jellywang
JJ娃 尿娃 水娃
精华贴数 1
个人空间
10
技术积分 4769 (326)
社区积分 7210 (247)
注册日期 2006-12-17
论坛徽章:57
#4
使用道具
发表于 2007-7-9 21:57
牛
__________________
钱不是问题,问题是没钱!
JJ之水天上来,灌到海区不复回!!
空空如也!!
只看该作者
lixuezhen
探险者
精华贴数 0
个人空间
0
技术积分 398 (5446)
社区积分 226 (2530)
注册日期 2006-11-10
论坛徽章:1
#5
使用道具
发表于 2007-7-12 15:46
Re: sql实现当月日历
QUOTE:
最初由 wngsheng 发布
select max(su) su,max(mo) mo,max(tu) tu,max(we) we,max(th) th,max(fr) fr,max(sa) sa from
(select case when d=1 then dd end su,
case when d=2 then dd end mo,
case when d=3 then dd end tu,
case when d=4 then dd end we,
case when d=5 then dd end th,
case when d=6 then dd end fr,
case when d=7 then dd end sa,
d,w,iw
from(
select dates,to_char(dates,'dd') dd,to_number(to_char(dates,'d')) d,to_char(dates,'w') w,to_char(dates+1,'iw') iw from
(select trunc(sysdate,'month')+level-1 dates from dual
connect by rownum<last_day(sysdate)-trunc(sysdate,'month')
)
)
)
group by iw
order by iw;
环境:oracle 10g
代码格式缩进一下,看看清楚都好啊
唉
__________________
继续顶红
只看该作者
goodhawk
因为专注,所以专业
来自 上海
精华贴数 1
个人空间
0
技术积分 2267 (790)
社区积分 5 (17357)
注册日期 2004-10-5
论坛徽章:9
#6
使用道具
发表于 2007-7-12 17:27
非常好。以前也想写,没写出来。
稍微纠正一下。 最后那个要 + 1
LAST_DAY (SYSDATE)- TRUNC (SYSDATE, 'month') + 1
__________________
真,善,美
*nix , Oracle,Oracle ERP (Fin),Php
blog:
http://www.xiaobaicai.com
Tech:
http://www.appsboss.com
只看该作者
kso
Just do it!
精华贴数 0
个人空间
0
技术积分 2518 (701)
社区积分 118 (3600)
注册日期 2005-5-6
论坛徽章:24
#7
使用道具
发表于 2007-7-12 17:33
9i下也适用..
__________________
执子之手,与子偕老。
只看该作者
pqxpqx
一般会员
精华贴数 0
个人空间
0
技术积分 260 (8252)
社区积分 0 (957453)
注册日期 2006-5-22
论坛徽章:0
#8
使用道具
发表于 2007-7-12 17:36
创意不错,楼主真牛。
只看该作者
wangfans
精华贴数 4
个人空间
20
技术积分 11520 (120)
社区积分 12586 (142)
注册日期 2006-11-29
论坛徽章:115
#9
使用道具
发表于 2007-7-12 17:58
牛尹~~~~
__________________
-------------------------------------------------
Life is always like this !
-------------------------------------------------
MSN: wangfans@163.com
-------------------------------------------------
只看该作者
sudan521
初级会员
精华贴数 0
个人空间
0
技术积分 4 (157527)
社区积分 0 (191531)
注册日期 2004-10-21
论坛徽章:0
#10
使用道具
发表于 2007-7-12 18:14
2007年8月 9月显示问题
select max(su) su,max(mo) mo,max(tu) tu,max(we) we,max(th) th,max(fr) fr,max(sa) sa from
(select case when d=1 then dd end su,
case when d=2 then dd end mo,
case when d=3 then dd end tu,
case when d=4 then dd end we,
case when d=5 then dd end th,
case when d=6 then dd end fr,
case when d=7 then dd end sa,
d,w
from(
select dates,to_char(dates,'dd') dd,to_number(to_char(dates,'d')) d,to_char(dates,'w') w,to_char(dates+1,'iw') iw from
(select trunc(sysdate,'month')+level-1 dates from dual
connect by rownum<last_day(sysdate)-trunc(sysdate,'month')+1
)
)
)
group by w
order by w;
//8月
SU MO TU WE TH FR SA
-- -- -- -- -- -- --
05 06 07 01 02 03 04
12 13 14 08 09 10 11
19 20 21 15 16 17 18
26 27 28 22 23 24 25
29 30 31
//9月
SU MO TU WE TH FR SA
-- -- -- -- -- -- --
02 03 04 05 06 07 01
09 10 11 12 13 14 08
16 17 18 19 20 21 15
23 24 25 26 27 28 22
30 29
只看该作者
13
1/2
1
2
››
投票
交易
悬赏
活动
相关内容
ITPUB论坛
≡ 数据库技术 ≡
> Oracle数据库管理
> Oracle高可用
> Oracle开发
> Oracle Developer Suite
> Oracle入门与认证
> Oracle专题深入讨论
> Oracle新技术/11g
> Oracle电子文档
> Oracle Fusion中间件
> IBM信息管理
> MS SQL Server
> Sybase管理与开发
> MySQL及其它开源数据库
> 内存数据库
> 数据仓库与数据挖掘
> 移动及嵌入式数据库
≡ 企业信息化 ≡
> ERP产品与实践
> CRM产品与实践
> HR产品与实践
> 物流
> 供应链
> 供应链建模与仿真
> 物流设备与系统工程
> 企业管理咨询
> 管理协同与办公自动化
> IT服务管理
> 数据中心建设与设备采购
> ERP二次开发
> Oracle ERP
> Oracle EBS R12
> PeopleSoft与JDE
> EBS相关文档
> SAP R/3
> SAP Business One开发与快速实施
> SAP财务及CRM
> SAP后勤及HR
> mySAP ERP
> 系统开发及跨应用设置
> SAP相关文档
> 国外其它ERP产品
> 国内ERP产品
≡ 开发技术 ≡
> Java入门与认证版
> Java web开发及框架技术
> Java企业开发
> WEB程序开发
> WEB 2.0技术
> 动态语言
> 移动与游戏开发
≡ 微软技术 ≡
> 开发工具和语言
> .NET Framework 相关
> Visual Basic/VB.net
> Visual C#
> Visual C++/vc.net
> Visual Studio
> .NET软件架构与模式
> .NET开发辅助工具及框架
> Web开发
> ASP.NET与AJAX
> Web相关技术讨论(IIS等)
> Silverlight 技术
> 微软企业级产品技术
> SQL Server
> windows server
> SharePoint
> Exchange Server
> Biztalk
> 嵌入式及移动开发
> Windows 移动设备
> Windows Embedded 嵌入式技术
> Office开发
> Microsoft office system
> Office Business Application
> 微软产品用户交流区
> .Net人才交流
> .Net电子书籍&&书籍介绍
≡ 系统设计与项目管理 ≡
> 系统分析与UML
> 系统分析与UML精华区
> 项目管理
> 项目过程
> 软件测试
> 算法讨论与研究
≡ IBM软件技术园地 ≡
> IBM信息管理
> Lotus
> Tivoli
> Websphere
> Rational
> 与SOA相关的IBM产品与技术
> IBM蓝色之路
> IBM软件技术精英协会
> 软件技术精英活动专版
≡ 操作系统与硬件 ≡
> AIX及IBM产品【已迁移到IXPUB】
> HP-UX及HP产品【已迁移到IXPUB】
> Solaris及SUN产品【已迁移到IXPUB】
> Linux及其应用 【已迁移到IXPUB】
> 其它UNIX系统【已迁移到IXPUB】
> windows系统及微软相关产品 【已迁移到IXPUB】
> 存储设备与容灾技术 【已迁移到IXPUB】
> 服务器 【已迁移到IXPUB】
≡ 行业纵向讨论区 ≡
> IT业界评论与展望
> 政府与教育事业
> 中国政府信息主管联盟
> 电信行业
> 金融行业
> 制造行业
> 医卫行业
> 电力行业
> 信息安全与审计
≡ 会员交流 ≡
> IT职业生涯
> 招聘求职商务信息
> 投资理财
> 体育世界
> 体育博彩专版
> 汽车世界
> 旅游,驴友
> 外语角
> 数码摄影
> 你的故事我的歌
> 音乐推荐区
> 电子图书与IT文档资料
> 软件交流
> 软件交流精华区
≡ ITPUB产品与服务 ≡
> ITPUB地面活动专版
> BLOG天地
> 授权用户区
> 站务管理
≡ 企业内容管理用户组 ≡
> ECM应用与解决方案
> 内容仓库管理
> 商业流程管理
> 内容及邮件归档管理
> 企业级搜索与分析
> 用户协会事务区
技术积分榜
社区积分榜
徽章
电子杂志
团队
统计
邮箱
游乐场
帮助
TOP
CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰网域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:060528号
联系我们
法律顾问
控制面板首页
编辑个人资料
积分交易
公众用户组
好友列表
升级您的博客
基本概况
论坛排行
主题排行
发帖排行
积分排行
在线时间
管理团队
管理统计