怎样用SQL语句统计USER列的"1"数量,要能返回值的。
1个回答
展开全部
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询