如果是ORACLE: select (select count(distinct 学生专业) from 表 where 学生姓名='张三')/(select count(distinct 学生专业) from 表) from dualdual是ORACLE中的系统临时表
我想在同一个查询里实现 select StudentName,StudentSex,"百分比"=(count(StudentZY))/(count(distinct Studentzy)) from StudentJBQK Where StudentSex='woman' group by StudentName,StudentSex这个方法不对.以下是结果 学生名 性别 百分比 A1 woman 1 Q1 woman 1
oracle_lover(数据库情人) 你说的不对,我想要的功能是:性别是女生的,学的专业占全部专业的百比分.不用你第一种的方法,select Studentid,"百分比"=(select count(distinct studentzy) from studentJBQK where Studentsex='woman')/(select count(distinct Studentzy) from studentJBQK) from studentJBQk执行之后百分比都为,0
在我这里执行相同的语句(字段名,表名不同,结构完全一样),结果正确 select nf,(select count(distinct bm) from qgb_bggz where bm='物资部')/(select count(distinct bm) from qgb_bggz) from qgb_bggz;你分别测试一下两个子查询,看结果对不对
我也执行了,结果为0.还是不对. select "百分比"=(select count(distinct StudentZy) from studentJBQK where studentsex='woman')/(select count(distinct studentzy) from studentJBQK)
我是说你分别测试一下 select count(distinct StudentZy) from studentJBQK where studentsex='woman'select count(distinct studentzy) from studentJBQK
select (select count(distinct 学生专业) from 表 where 学生姓名='张三')/(select count(distinct 学生专业) from 表) from dualdual是ORACLE中的系统临时表
select StudentName,StudentSex,"百分比"=(count(StudentZY))/(count(distinct Studentzy))
from StudentJBQK
Where StudentSex='woman'
group by StudentName,StudentSex这个方法不对.以下是结果
学生名 性别 百分比
A1 woman 1
Q1 woman 1
from studentJBQk执行之后百分比都为,0
select nf,(select count(distinct bm) from qgb_bggz where bm='物资部')/(select count(distinct bm) from qgb_bggz) from qgb_bggz;你分别测试一下两个子查询,看结果对不对
select "百分比"=(select count(distinct StudentZy) from studentJBQK where studentsex='woman')/(select count(distinct studentzy) from studentJBQK)
select count(distinct StudentZy) from studentJBQK where studentsex='woman'select count(distinct studentzy) from studentJBQK