1、若针对每行求百分比: select SA/TotelTime ,SB/TotelTime ,SC/TotelTime ,SD/TotelTime ,SE/TotelTime from 表名 。
2、若是对总计后的值求百分比: select sum(SA)/sum(TotelTime) ,sum(SB)/sum(TotelTime) ,sum(SC)/sum(TotelTime) ,sum(SD)/sum(TotelTime) ,sum(SE)/sum(TotelTime) from 表名
3、当然,以上都是以小数形式显示结果,若要以百分比形式显示结果:乘以100,并保留两位小数,然后加上“%”即可。
如:round((SA/TotelTime)*100,2) & "%"
select mz as '民族',count(*) as '人数',SUBSTRING (convert(varchar (20)
(count(*)/80.00*100) ),1,4)+'%' as '比例' from ryxx group by mz
语音朗读: