一,简介
1.sql数据
2.题目以及答案
*1、查询课程1的成绩 比 课程2的成绩 高 的所有学生的学号.
SELECT a.sno ,a.score,b.score from (SELECT sno ,score from j_score where cno = '1') a ,
(SELECT sno ,score from j_score where cno = '2') b
WHERE a.score > b.score and a.sno = b.sno
2、查询平均成绩大于60分的同学的学号和平均成绩
SELECT sno,AVG(score) FROM j_score GROUP BY sno HAVING AVG(score)>60
3、查询所有同学的学号、姓名、选课数、总成绩
SELECT s.sno,s.sname,COUNT(sc.cno),SUM(sc.score) FROM j_student s LEFT OUTER JOIN
j_score sc ON s.sno=sc.sno GROUP BY s.sno,s.sname
4、查询姓“李”的学生的个数;
SELECT COUNT(*) FROM j_student WHERE sname LIKE "李%";
*5、查询没学过“叶平”老师课的同学的学号、姓名;
SELECT sno,sname FROM j_student WHERE sno NOT IN(
SELECT DISTINCT sno FROM j_score WHERE cno IN
(SELECT