SELECT stu.stuid,couid,score
FROM stu
JOIN scores ON stu.stuid=scores.stuid
WHERE stu.stuid=20070102;
SELECT stu.stuid,stuname,sex,couname,score
FROM stu JOIN scores ON stu.stuid=scores.stuid
JOIN course ON scores.couid=course.couid
WHERE stu.stuid=20070102;
SELECT stu.stuid,stuname
FROM stu JOIN scores ON stu.stuid=scores.stuid
JOIN course ON scores.couid=course.couid
WHERE couname=“英语”;
SELECT stu.stuid,stuname,couname,score
FROM course JOIN scores ON course.couid=scores.couid
JOIN stu ON scores.stuid=stu.stuid
JOIN dep ON stu.depid=dep.depid
WHERE depname=“电子信息系”;
SELECT stu.stuid,stuname,couname,score
FROM course JOIN scores ON course.couid=scores.couid
JOIN stu ON scores.stuid=stu.stuid
JOIN dep ON stu.depid=dep.depid;
SELECT stu.stuid,stuname,score
FROM course JOIN scores ON course.couid=scores.couid
JOIN stu ON scores.stuid=stu.stuid
WHERE depid=1001 AND couname=“高等数学”;
SELECT depname,COUNT(*)
FROM stu JOIN dep ON stu.depid=dep.depid
GROUP BY dep.depid;
SELECT couname,AVG(score)
FROM course JOIN scores ON course.couid=scores.couid
GROUP BY couname;
SELECT depname,couname,AVG(score)
FROM course JOIN scores ON course.couid=scores.couid
JOIN stu ON scores.stuid=stu.stuid
JOIN dep ON stu.depid=dep.depid
GROUP BY depname,couname;
SELECT stu.stuid,COUNT(score>80)
FROM stu JOIN scores ON stu.stuid=scores.stuid
WHERE score>80
GROUP BY stu.stuid
HAVING count(couid)>2;
SELECT stu.stuid
FROM stu JOIN scores ON stu.stuid=scores.stuid
WHERE score>60
GROUP BY couid
HAVING AVG(score)>=85;
SELECT AVG(score)
FROM course JOIN scores ON course.couid=scores.couid
WHERE couname=“英语”
GROUP BY couname;
SELECT stu.stuid,stuname
FROM stu JOIN scores ON stu.stuid=scores.stuid
WHERE couid NOT IN
(SELECT DISTINCT couid FROM scores);
SELECT course.couid,couname
FROM course JOIN scores ON course.couid=scores.couid
WHERE course.couid NOT IN
(SELECT couid FROM course);
以上仅为个人练习操作,如有错误欢迎指正!!!