请教一个SQL的除法过程----在线等

jia19861029 jia19861029 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
数据库为:sql server2000
SQL语句为:
select distinct pname,
(select count(*) from baseinfo as a where (jjgz='1' or jjgz='2') and a.pname=b.pname ) as count1,
(select count(*) from baseinfo as a where a.pname=b.pname ) as count2 ,

(select count(*) from baseinfo as a where (jjgz='1' or jjgz='2') and a.pname=b.pname )/
(select count(*) from baseinfo as a where a.pname=b.pname ) as count3
from baseinfo as b order by count1 desc

得到的结果为:
pname count1 count2 count3
张三 1101 1104 0



如何让count3有小数点后四位或者更多呢?如何给count3加上“%”号呢?
...全文
评论 8
收藏 已收藏
分享
返回顶部
jia19861029
Java SE 62,620 成员 307,251 内容