惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 左少白

oracle 找回DROP掉的表 求解,工作流点通过时,弹出窗口让用户录入审核意见 oracle 游标 c# 多态 sqlserver 按五分钟分组 c# 继承 SqlParameter序列化的问题 oracle oracle trunc (date,dd )函数 oracle 游标 对象集合转换为datatable 用C# 正则 提取HTML标签中的值? oracle decode 与 case when ,空的处理 oracle select for update sql1 同期进度,完成率 Oracle Index 相關知識 玩转DevExpress.XtraGrid.view.gridview oracle索引 在Oracle中进行大小写不敏感的查询2 - 左少白
查询行转列
左少白 · 2011-06-01 · via 博客园 - 左少白

SELECT to_date(to_char(last_day(add_months(SYSDATE, -2))+1,'yyyy-mm-dd'),'yyyy-mm-dd'),to_date(to_char(last_day(add_months(SYSDATE, -1)),'yyyy-mm-dd'),'yyyy-mm-dd')   FROM dual;

SELECT to_date(to_char(last_day(add_months(SYSDATE, -3))+1,'yyyy-mm-dd'),'yyyy-mm-dd'),to_date(to_char(last_day(add_months(SYSDATE, -2)),'yyyy-mm-dd'),'yyyy-mm-dd')   FROM dual;

SELECT to_date(to_char(last_day(add_months(SYSDATE, -4))+1,'yyyy-mm-dd'),'yyyy-mm-dd'),to_date(to_char(last_day(add_months(SYSDATE, -3)),'yyyy-mm-dd'),'yyyy-mm-dd')   FROM dual;

1: select sum(case when to_char(billingdate,'yyyy-mm') =to_char(last_day(add_months(SYSDATE, 0)),'yyyy-mm') then quantity else 0 end) currentmonthquantity, 

          sum(case when to_char(billingdate,'yyyy-mm') =to_char(last_day(add_months(SYSDATE, -1)),'yyyy-mm') then quantity else 0 end) , 

          sum(case when to_char(billingdate,'yyyy-mm') =to_char(last_day(add_months(SYSDATE, -2)),'yyyy-mm') then quantity else 0 end), 

          sum(case when to_char(billingdate,'yyyy-mm') =to_char(last_day(add_months(SYSDATE, -3)),'yyyy-mm') then quantity else 0 end) , 

          prodid,branchid,sum(quantity) quantity From (

             select * From tb_gos_sale_salestockoutdet

             where billingdate between to_date(to_char(last_day(add_months(SYSDATE, -4))+1,'yyyy-mm-dd'),'yyyy-mm-dd') and sysdate

         ) group by prodid,branchid

         having prodid='SPH00013655' 

2:   select * From (

   select to_char(billingdate,'yyyy-mm') billdate,prodid,branchid,sum(quantity) quantity From (

             select * From tb_gos_sale_salestockoutdet

             where billingdate between to_date(to_char(last_day(add_months(SYSDATE, -4))+1,'yyyy-mm-dd'),'yyyy-mm-dd') and sysdate

         ) group by to_char(billingdate,'yyyy-mm'),prodid,branchid

         having prodid='SPH00013655'

         )

          pivot 

          (

             sum(quantity)

             for billdate in ('2011-03' as 三月销售,'2011-04','2011-05','2011-06')

          )