SELECT * FROM test5 ;

RESOURCES DATETIME CNT ID
1 0 2018-01-22 4 1
2 0 2018-01-24 10 2
3 0 2018-01-25 25 3
4 0 2018-01-26 14 4
5 0 2018-01-29 3 5
6 1 2018-01-29 22 6
7 2 2018-01-29 1 7
8 1 2018-01-30 44 8
9 2 2018-01-30 7 9
10 2 2018-01-31 1 10
11 2 2018-02-01 1 11

、、、、、、、、、、、、

SELECT datetime, sum(case when resources=0 then cnt else null end) as anzhuo,
sum(case when resources=1 then cnt else null end) as ios,
sum(case when resources=2 then cnt else null end) as houtai
FROM test5 t
group by t.datetime
;

、、、、、、、、、、、、、、

DATETIME ANZHUO IOS HOUTAI
1 2018-01-25 25
2 2018-01-24 10
3 2018-01-26 14
4 2018-01-31 1
5 2018-01-30 44 7
6 2018-01-29 3 22 1
7 2018-01-22 4
8 2018-02-01 1

 

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2022-02-15
猜你喜欢
  • 2021-07-28
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
相关资源
相似解决方案