急,急,急 pl/sql ,oracle 根据查询结果统计数量
有一张表student_mart,有一下字段信息,project:科目,值为语文、数学、英语mark:成绩,值为A、B、C、D现在要求写一个效率不错的sql:统计这张表中...
有一张表 student_mart,有一下字段信息 ,
project:科目,值为语文、数学、英语
mark:成绩,值为A、B、C、D
现在要求写一个效率不错的sql:统计这张表中语文成绩为D的条数,数学成绩为D的条数,英语成绩为D的条数。
提问没有提好,不好意思各位。
在加一个字段:calssno :班级。我想统计出下面的这个种结果。 展开
project:科目,值为语文、数学、英语
mark:成绩,值为A、B、C、D
现在要求写一个效率不错的sql:统计这张表中语文成绩为D的条数,数学成绩为D的条数,英语成绩为D的条数。
提问没有提好,不好意思各位。
在加一个字段:calssno :班级。我想统计出下面的这个种结果。 展开
4个回答
展开全部
select A.calssno, A.count_1, B.count_2, C.count_3
from
(select count(*) as count_1, calssno
from student_mart
where project = '语文'
and mark = 'D'
group by calssno) A,
(select count(*) as count_2, calssno
from student_mart
where project = '数学'
and mark = 'D'
group by calssno) B,
(select count(*) as count_3, calssno
from student_mart
where project = '英语'
and mark = 'D'
group by calssno) C
where A.calssno = B.calssno
and B.calssno = C.calssno
from
(select count(*) as count_1, calssno
from student_mart
where project = '语文'
and mark = 'D'
group by calssno) A,
(select count(*) as count_2, calssno
from student_mart
where project = '数学'
and mark = 'D'
group by calssno) B,
(select count(*) as count_3, calssno
from student_mart
where project = '英语'
and mark = 'D'
group by calssno) C
where A.calssno = B.calssno
and B.calssno = C.calssno
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
展开全部
SELECT calssno, 语文成绩为A的条数=COUNT(CASE WHEN project='语文' AND mark='A' THEN 1 END),数学成绩为B的条数=COUNT(CASE WHEN project='数学' AND mark='B' THEN 1 END),
英语成绩为C的条数=COUNT(CASE WHEN project='英语' AND mark='C' THEN 1 END)
FROM student_mart
GROUP BY calssno
英语成绩为C的条数=COUNT(CASE WHEN project='英语' AND mark='C' THEN 1 END)
FROM student_mart
GROUP BY calssno
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select count(*) from student_mart where mark='D' and project='语文'
union
select count(*) from student_mart where mark='D' and project='数学'
union
select count(*) from student_mart where mark='D' and project='英语'
union
select count(*) from student_mart where mark='D' and project='数学'
union
select count(*) from student_mart where mark='D' and project='英语'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select project,count(*) from student_mart t where t.mark='D' group by t.project
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询