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

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - 老头

简易OA漫谈之工作流设计(六,快捷表单和动态表单) 简易OA漫谈之工作流设计(五,直接上级) 简易OA漫谈之工作流设计(四,怎么支持会签) 简易OA漫谈之工作流设计(一个Demo),完成6年前的一个贴子 bom头 ERP产品价格成本计算的几个方法 简易OA漫谈之工作流设计(DB实现) 简易OA漫谈之工作流设计(DB) charindex使用一个异常记录思考 开发人员死得很惨的一个问题 程序员半夜泡奶粉,睡不着了 web效率14條規則(轉) 使用mht格式做多sheet excel報表 Gridview小技巧-保存選擇狀態 SOA、反射+緩存 擴展Membership建立中小型WEB權限框架(一) 一个简单的WEB流程图组件[demo] 常用javascript 表達式驗證[綜合轉載] 数据表的设计原则(轉載)
sql server 2005行列轉換
老头 · 2008-12-16 · via 博客园 - 老头

ProductID OrderMonth SubTotal
1 5 100.00
1 6 100.00
2 5 200.00
2 6 200.00
2 7 300.00
3 5 400.00
3 5 400.00

SELECT ProductID, [5] AS 五月, [6] AS 六月, [7] AS 七月
FROM
Sales.Orders PIVOT
(
SUM (Orders.SubTotal)
FOR Orders.OrderMonth IN
( [5], [6], [7] )
) AS pvt

ORDER BY ProductID;

把列轉成行用UNPIVOT,用處不大吧

CREATE TABLE MyPvt (ProductID int, 五月int, 六月 int, 七月int); --建立MyPvt表
GO
  --将表5-5中所示的值插入到MyPvt表中

INSERT INTO MyPvt VALUES (1,100,100,0);
INSERT INTO MyPvt VALUES (2,200,200,200);
INSERT INTO MyPvt VALUES (3,800,0,0);

  --执行UNPIVOT

SELECT ProductID, OrderMonth, SubTotal
FROM
 MyPvt UNPIVOT
 (SubTotal FOR OrderMonth IN
  (五月, 六月, 七月)
 )AS unpvt;