统计logic java 课程最近一次考试学生应到人数,实到人数,缺考人数。

统计logic java 课程最近一次考试学生应到人数,实到人数,缺考人数。
提取logic java 课程最近一次考试的成绩信息并保存结果。成绩信息包括学生姓名、学号考试成绩。

logic java 最近考试日期

SELECT MAX(examdate) FROM result
WHERE subjectno = (
#logic java 科目编号
SELECT subjectNo FROM SUBJECT WHERE subjectName = ‘Logic Java’
)

logic java 课程所属年级

SELECT gradeId FROM SUBJECT WHERE subjectName = ‘Logic Java’

logic java 课程所属年级编号

SELECT subjectNo FROM subject WHERE subjectName = ‘Logic java’

应到人数

SELECT * FROM student WHERE gradeId = (
#logic java 课程所属年级
SELECT gradeId FROM SUBJECT WHERE subjectName = ‘Logic Java’
)

实到人数
SELECT *FROM result
WHERE subjectNO = (
#logic java 课程所属年级编号
SELECT subjectNo FROM subject WHERE subjectName = ‘Logic java’
)
AND examdate = (
SELECT MAX(examdate) FROM result
WHERE subjectno = (
#logic java 科目编号
SELECT subjectNo FROM SUBJECT WHERE subjectName = ‘Logic Java’)
)

统计logic java 课程最近一次考试学生应到人数,实到人数,缺考人数。

SELECT
(#应到人数
SELECT COUNT(*) FROM student WHERE gradeId = (
#logic java 课程所属年级
SELECT gradeId FROM SUBJECT WHERE subjectName = ‘Logic Java’)) AS >>’应到人数’,

(#实到人数
SELECT COUNT(*) FROM result
WHERE subjectNO = (
#logic java 课程所属年级编号
SELECT subjectNo FROM subject WHERE subjectName = ‘Logic java’)) AS ‘实到人数’,

((#应到人数
SELECT COUNT(*) FROM student WHERE gradeId = (
#logic java 课程所属年级
SELECT gradeId FROM SUBJECT WHERE subjectName = ‘Logic Java’)) -

(#实到人数
SELECT COUNT(*) FROM result
WHERE subjectNO = (
#logic java 课程所属年级编号
SELECT subjectNo FROM subject WHERE subjectName = ‘Logic java’)))AS ‘缺考人数’

提取logic java 课程最近一次考试的成绩信息并保存结果。成绩信息包括学生姓名、学号考试成绩。

提取学生的成绩信息并保存结果,包括学生姓名,学号和考试成绩。

SELECT student.studentName,student.studentNO,r.studentresult
FROM student LEFT JOIN(
#实到人数
SELECT * FROM result
WHERE subjectNO = (
#logic java 课程所属年级编号
SELECT subjectNo FROM subject WHERE subjectName = ‘Logic java’)
AND examdate = (
SELECT MAX(examdate) FROM result
WHERE subjectno = (
#logic java 科目编号
SELECT subjectNo FROM SUBJECT WHERE subjectName = ‘Logic Java’))
) AS r ON student.studentNo = r.studentNo
WHERE gradeId = (
#logic java 课程所属年级
SELECT gradeId FROM SUBJECT WHERE subjectName = ‘Logic Java’
)

DROP TABLE IF EXISTS tempResult;

CREATE TABLE tempTesult(
#提取学生的成绩信息并保存结果,包括学生姓名,学号和考试成绩。
SELECT student.studentName,student.studentNO,r.studentresult
FROM student LEFT JOIN(
#实到人数
SELECT * FROM result
WHERE subjectNO = (
#logic java 课程所属年级编号
SELECT subjectNo FROM subject WHERE subjectName = ‘Logic java’)
AND examdate = (
SELECT MAX(examdate) FROM result
WHERE subjectno = (
#logic java 科目编号
SELECT subjectNo FROM SUBJECT WHERE subjectName = ‘Logic Java’))
) AS r ON student.studentNo = r.studentNo
WHERE gradeId = (
#logic java 课程所属年级
SELECT gradeId FROM SUBJECT WHERE subjectName = ‘Logic Java’)
);

你可能感兴趣的:(mysql)