请教一个SQL的除法过程----在线等
数据库为: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加上“%”号呢?
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加上“%”号呢?
...全文
相关推荐
sql语句的除法表示
如何将sql中的除法关系通过sql语句来实现,历来是一个难题!
关系代数中_除法_运算的SQL查询实现
关系代数中_除法_运算的SQL查询实现,可以学会关系代数据除如何用SQL实现
sql的除法知识,有关除法的解释
查询至少学习了学生‘95002’所学课程的学生学号 :ΠSno,Cno(SC)÷(ΠCno(σSno=‘95002’(SC))) 求解过程分解为:分别从学生表中拿出每一个学生,判断是否学习了学生“95002”所学课程,如果是,则将其显示在结果中,否则不显示,直至将所有学生记录取完。例如取出学生“李勇”,通过判断李勇是否学习了学生“95002”所学课程来决定李勇是否满足查询条件,然后取出刘晨进行判断直至最后。
MSSQL中进行SQL除法运算结果为小数却显示0的解决方法
主要介绍了MSSQL中进行SQL除法运算结果为小数却显示0的解决方法,需要的朋友可以参考下
数据库关系除法转SQL
能够让你从理论上深刻的了解数据库中关系除法转换成SQL 很好的东东.


Java SE
