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

推荐订阅源

博客园 - Franky
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
博客园 - 司徒正美
D
Docker
T
The Blog of Author Tim Ferriss
罗磊的独立博客
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
J
Java Code Geeks
Jina AI
Jina AI
博客园 - 【当耐特】
C
Check Point Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog

博客园 - gotolovo

导出csv 导出excel 正则学习电话匹配 logmanager des 加密 解密 - gotolovo c# 发送邮件 工作流学习过程-事务 工作流学习过程-状态机 蛋疼的viewstate 工作流学习过程-持久化服务 工作流学习过程-使用关联 工作流学习过程-本地服务之事件处理 工作流学习过程-本地服务之调用方法 工作流学习过程-验证活动 工作流学习过程-自定义活动 工作流学习过程-开篇 基本的几个排序算法 关于sql中时间的格式转换 请编程遍历页面上所有TextBox控件并给它赋值为空
数据行变列
gotolovo · 2010-06-25 · via 博客园 - gotolovo
CREATE TABLE [dbo].[Table_2](
	[rq] [datetime] NOT NULL,
	[shengfu] [nvarchar](4) NOT NULL
) ON [PRIMARY]


--insert into Table_2(rq,shengfu) values('2010-9-1','胜')
--insert into Table_2(rq,shengfu) values('2010-9-1','胜')
--insert into Table_2(rq,shengfu) values('2010-9-1','负')
--insert into Table_2(rq,shengfu) values('2010-9-1','负')
--insert into Table_2(rq,shengfu) values('2010-9-2','负')
--insert into Table_2(rq,shengfu) values('2010-9-2','负')
--insert into Table_2(rq,shengfu) values('2010-9-2','负')
--insert into Table_2(rq,shengfu) values('2010-9-2','胜')

生成格式如下:

rq
2010-09-01 2 3
2010-09-02 1 3

select rq, sum(CASe when shengfu ='胜' then 1 else 0 end) as 胜,
sum( CASe when shengfu ='负' then 1 else 0 end) as 负
from Table_2
group by rq