学生表: 成绩表: 向两个表中插入数据: 1 从student表中查询每个院系有多少人2 从score表中查询每个科目的最高分3 查询李四的考试科目和考试成绩4 查询所有学生的信息和考试信息5 计算每个学生的总成绩6 计算每个考试科目的平均成绩7 查询计算机成绩低于95的学生信息8 将计算机考试成绩按从高到低进行排序9 查询姓张或姓王的学生的姓名、院系和考试科目及成绩10 查询都是湖南的学生的姓名
- SELECT department, COUNT(*) FROM student GROUP BY department;
- SELECT subject, MAX(score) FROM score GROUP BY subject;
- SELECT subject, score FROM score WHERE student_id = (SELECT id FROM student WHERE name = '李四');
- SELECT student.*, score.subject, score.score FROM student INNER JOIN score ON student.id = score.student_id;
- SELECT name, SUM(score) FROM student INNER JOIN score ON student.id = score.student_id GROUP BY name;
- SELECT subject, AVG(score) FROM score GROUP BY subject;
- SELECT student.* FROM student INNER JOIN score ON student.id = score.student_id WHERE score.subject = '计算机' AND score.score < 95;
- SELECT * FROM score WHERE subject = '计算机' ORDER BY score DESC;
- SELECT student.name, student.department, score.subject, score.score FROM student INNER JOIN score ON student.id = score.student_id WHERE student.name LIKE '张%' OR student.name LIKE '王%';
- SELECT student.name, student.age, student.department, score.subject, score.score FROM student INNER JOIN score ON student.id = score.student_id WHERE student.province = '湖南'
原文地址: http://www.cveoy.top/t/topic/g0Sw 著作权归作者所有。请勿转载和采集!