1、先从一个题目说起,有一个info表,表结构和测试数据如下,我们想要的效果是,把这些result按输赢来再加一列,分别是win列和lose列,列的内容是win或lose的数量,最后按照日期来分组排。

SQL中行转列的语句

 

2、下面是SQL语句:

select date, 

count(case when result = 'win' then result end) win, 
count(case when result = 'lose' then result end) lose 
from info 

group by date;

效果图如下:

SQL中行转列的语句

相关文章:

  • 2021-05-26
  • 2021-09-01
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2021-12-30
  • 2021-12-22
相关资源
相似解决方案