沧州响应式网站开发,营销类网站有哪些,办一家建筑公司流程,企业营销策划案例分析以前做过一道题目#xff0c;一直没有来得及总结下来。贴图#xff1a; 记得以前曾经找到了两种方法#xff0c;今天试了一下#xff0c;还是可以的#xff0c;贴出过程#xff1a; 下面是具体的查询方法#xff1a; 原来放的是图片,今天又练习了一下,附代码: 1 create … 以前做过一道题目一直没有来得及总结下来。贴图 记得以前曾经找到了两种方法今天试了一下还是可以的贴出过程 下面是具体的查询方法 原来放的是图片,今天又练习了一下,附代码: 1 create TABLE #Match2 (3 matchDate datetime,4 matchResult nvarchar(20)5 )6 7 insert #Match select 2014-09-01,lost8 select 2014-09-19,win9 union all
10 select 2014-09-19,win
11 union all
12 select 2014-09-19,lost
13 union all
14 select 2014-09-01,win
15 union all
16 select 2014-09-19,lost
17 union all
18 select 2014-09-01,lost
19
20
21 select * from #Match
22
23
24 --方法1
25 select m.matchDate,
26 sum(case when m.matchResultwin then 1 else 0 end) win,
27 sum(case when m.matchResultlost then 1 else 0 end) lost
28 from #Match m group by m.matchDate
29
30
31 --方法2
32 select m.matchDate,
33 sum(case m.matchResult when win then 1 else 0 end) win,
34 sum(case m.matchResult when lost then 1 else 0 end) lost
35 from #Match m group by m.matchDate View Code 转载于:https://www.cnblogs.com/hshuai/p/3584191.html