1. SELECT department, COUNT(*) FROM student GROUP BY department;
  2. SELECT subject, MAX(score) FROM score GROUP BY subject;
  3. SELECT subject, score FROM score WHERE student_id = (SELECT id FROM student WHERE name = '李四');
  4. SELECT student.*, score.subject, score.score FROM student INNER JOIN score ON student.id = score.student_id;
  5. SELECT name, SUM(score) FROM student INNER JOIN score ON student.id = score.student_id GROUP BY name;
  6. SELECT subject, AVG(score) FROM score GROUP BY subject;
  7. SELECT student.* FROM student INNER JOIN score ON student.id = score.student_id WHERE score.subject = '计算机' AND score.score < 95;
  8. SELECT * FROM score WHERE subject = '计算机' ORDER BY score DESC;
  9. 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 '王%';
  10. 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 = '湖南';
SQL数据库操作:学生表和成绩表实战练习

原文地址: https://www.cveoy.top/t/topic/ozE6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录