求这个字段里的 百分比占比Sql怎么写,如满意的占总数的百分之多少,不满意的占百分之多少?
1个回答
展开全部
with tt as (
select 1 as id,'满意' as grade union all
select 2 as id,'非常满意' as grade union all
select 3 as id,'满意' as grade union all
select 4 as id,'一般' as grade union all
select 5 as id,'很满意' as grade union all
select 6 as id,'不满意' as grade union all
select 7 as id,'满意' as grade union all
select 8 as id,'不满意' as grade union all
select 9 as id,'满意' as grade
)
select grade,COUNT(1) as 数量,convert(decimal(6,4),COUNT(1))/(select COUNT(*) from tt) as 百分比 from tt group by grade
北京埃德思远电气技术咨询有限公司
2023-08-25 广告
2023-08-25 广告
"整定计算的工作步骤,大致如下:1.确定整定方案所适应的系统情况。2.与调度部门共同确定系统的各种运行方式。3.取得必要的参数与资料(保护图纸,设备参数等)。4.结合系统情况,确定整定计算的具体原则。5.进行短路计算。6.进行保护的整定计算...
点击进入详情页
本回答由北京埃德思远电气技术咨询有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询