您的位置:首页 > 数据库

sql计算出百分比

2009-08-25 11:50 183 查看
Code

select a.level,a.Subtotal,b.total ,SUBSTRING (convert(varchar (20),(a.Subtotal*1.0/b.total*100)),1,4)+'%' as perTotal from

(

select level, COUNT(*) as Subtotal from T_UserInfo where VerSionID='V20081205002' group by Level

)a,

(

select COUNT(*) as total from T_UserInfo where VerSionID='V20081205002'

最后的结果
level Subtotal total perTotal

中 23 86 26.7%
低 26 86 30.2%
高 37 86 43.0%[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: