用sql语句得到指定日期所在的周是本年度第几周(Specify the date where the annual week was the first few weeks with the SQL statement).docVIP
- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
用sql语句得到指定日期所在的周是本年度第几周(Specify the date where the annual week was the first few weeks with the SQL statement)
用sql语句得到指定日期所在的周是本年度第几周(Specify the date where the annual week was the first few weeks with the SQL statement)
Specify the date where the annual week was the first few weeks with the SQL statement
Personal classification: SQL skills
Yesterday, a customer demand, demand has to be used for the specified date in the week was the year of the first few weeks
Seeing this question, I naturally think of the use of to_char (D,ww):
SQL, select, date2010-01-1+ rownum - 1 r,
2 to_char (date2010-01-1+ rownum - 1,d) -1 wn,
3 to_number (to_char (date2010-01-1+ rownum - 1,ww)) nthweek
4 from dual
5 connect by rownum = date2010-01-27- date2010-01-1 + 1
6 /
R WN NTHWEEK
Am
2010-1-1 51
2010-1-2 61
2010-1-3 01
2010-1-4 11
2010-1-5 21
2010-1-6 31
2010-1-7 41
2010-1-8 52
2010-1-9 62
2010-1-10 02
2010-1-11 12
2010-1-12 22
2010-1-13 32
2010-1-14 42
2010-1-15 53
2010-1-16 63
2010-1-17 03
2010-1-18 13
2010-1-19 23
2010-1-20 33
2010-1-21 43
2010-1-22 54
2010-1-23 64
2010-1-24 04
2010-1-25 14
2010-1-26 24
2010-1-27 34
27 rows selected
From the above data, the first group is the true color corresponding to the first week, but this function is the first 7 days as the first week, the first week of the first week with the actual difference of 4 days to four days, this led directly behind the data is not accurate. Seemingly online also did not find a direct solution to this problem Oracle system function, no way, had to write a SQL:
SQL with, TMP, as (select, date2010-01-27, D, from, dual)
2, select, R, wn,
3 sum (decode (WN, 1, 1, 0)) over (order, by, rownum) +
4 decode (to_char (TRUNC (D,y) - 1,d), 1,1,1) nthweek
5 from (select, TRUNC (D,y) + rownum - 1, R, d,
6 to_char (TRUNC (D,y) + rownum - 1,d) - 1 WN
7 from TMP
8 connect by - TRUNC rownum = D (D,y) + 1)
9 /
R WN NTHWEEK
Am
2010-1-1 51
2010-1-2 61
2010-1-3 01
2010-1-4 12
2010-1-5 22
2010-1-6 32
2010-1-7 42
2010-1-8 5 2
2010-1-9 6 2
2010-1-10 0 2
2010-1-11 1 3
2010-1-12 2 3
2010-1-13 3 3
2010-1-14 4 3
2010-1-15 5 3
2010-1-16 6 3
3什么0
2010-1-
您可能关注的文档
- 玻璃器具等的清洗、烘干、包扎、灭菌实验(Cleaning, drying, bandaging and sterilizing experiments of glassware).doc
- 玻璃分类(Glass classification).doc
- 现货盘面知识(Spot disk knowledge).doc
- 玻璃幕墙的施工方案及施工工艺(Construction scheme and construction technology of glass curtain wall).doc
- 玻璃材质(Glass material).doc
- 玻璃纤维桩修复残根残冠的临床观察(Clinical observation of glass fiber post for restoration of residual roots and crowns).doc
- 玻璃清洗(Glass cleaning).doc
- 珍珠奶茶制作方法(Method for making pearl milk tea).doc
- 玻璃检测(Glass inspection).doc
- 玻璃纤维增强型复合树脂桩核修复基牙折断烤瓷牙效果观察(Effect of glass fiber reinforced composite resin post core for restoration of abutment fracture of porcelain fused to tooth).doc
- 用visual c++实现qq界面的模拟(Simulation of QQ interface with visual c++).doc
- 用《周易》透析管理企业培训短板(Using Zhouyi to dialysis management enterprise training short board).doc
- 用于高硅铝合金的无氰沉锌液(Non cyanide zinc immersion liquid for high silicon aluminum alloy).doc
- 用openssl进行ssl编程(Programming with SSL using OpenSSL).doc
- 用什么软件能测试笔记本电脑是否稳定(What software can be used to test whether the laptop is stable).doc
- 用友u8存货核算流程(UF U8 inventory accounting process).doc
- 用大宇宙观透视互联网思维(Perspective of Internet thinking from the perspective of macrocosm).doc
- 用vc++ 6.0来编译wdm驱动(Compiling WDM drivers using vc++ 6).doc
- 用友u8年度账打印方法(总账明细账现金银行日记账)(UF U8 annual account printing method (ledger, subsidiary ledger, cash, bank journal)).doc
- 用户界面和易用性测试(User interface and usability testing).doc
文档评论(0)