--------------------------表结构--------------------------
student(StuId,StuName,StuAge,StuSex) 学生表
teacher(TId,Tname) 教师表
course(CId,Cname,C_TId) 课程表
sc(SId,S_CId,Score) 成绩表
----------------------------------------------------------
问题十四:查询和“1002”号的同学学习的课程完全相同的其他同学学号和姓名
SELECT StuId,StuName FROM student WHERE StuId= ANY( SELECT SId FROM sc WHERE SId NOT IN (SELECT SId FROM sc WHERE S_CId NOT IN (SELECT S_CId FROM sc WHERE SId='1002')) GROUP BY SId HAVING COUNT(*)= (SELECT COUNT(*) FROM sc WHERE SId='1002') ) AND StuId<>'1002';
答案仅供参考,不一定完全正确,若发现错误或有更好的,欢迎评论,互相交流,一起成长!!!