![](/img/trans.png)
[英]i want to count total number of males and females from the result of sub query. Is there any mysql query
[英]Stuck at query. I want total number of students in each board
我有两张桌子的学生和年级。
它们通过PK FK关系从学生(计数)到成绩(marksID)链接在一起。 明智地,我必须选择得分超过70%的学生所占的百分比。
每个城市都有自己的董事会。
查询是:
select g3.board,(count(g2.percentag)/ count(board))*100
from loadbise.grade as g2, loadbise.student as g3
where g2.marksID=g3.countt
and percentag > 70
group by g3.board;
我知道count(ge.percentag)和count(board)的值是相同的。
我被困在这一点。
我希望每个板的学生总数为count(board)。
我在想什么???
架构是..
检查此SQL查询。 我为每个董事会计算了百分比> 70的学生人数和学生总数。
SELECT T.board,
(SELECT COUNT(DISTINCT G.countt) FROM loadbise.Grades AS G
JOIN loadbise.Student AS S ON S.countt = G.countt
WHERE G.percentage > 70
AND S.board = T.board)
/
(SELECT COUNT(S.countt) FROM loadbise.Student AS S
WHERE S.board = T.board) * 100
FROM
(SELECT DISTINCT board
FROM Student AS S) AS T
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.