select bg_severity,count(*) as row_count
from 表名 group by bg_severity
結果:
bg_severity row_count
1-低 xx
2-中 xx
1-高 xx
select sum(case when bg_severity = N"1-低" then 1 else 0 end) as [1-低],
sum(case when bg_severity = N"2-中" then 1 else 0 end) as [2-中],
sum(case when bg_severity = N"3-高" then 1 else 0 end) as [3-高]
from 表名
1-低 |2-中 |3-高
xx |xx | xx
select bg_severity,count(*) as row_count
from 表名 group by bg_severity
結果:
bg_severity row_count
1-低 xx
2-中 xx
1-高 xx
select sum(case when bg_severity = N"1-低" then 1 else 0 end) as [1-低],
sum(case when bg_severity = N"2-中" then 1 else 0 end) as [2-中],
sum(case when bg_severity = N"3-高" then 1 else 0 end) as [3-高]
from 表名
結果:
1-低 |2-中 |3-高
xx |xx | xx