MySQL数据库技术

11.查询所有同学的学号、姓名、选课数、总成绩;

select Student.S_ID,Student.Sname,count(SC.C_ID),sum(score) from Student left Outer join SC on Student.S_ID=SC.S_ID group by Student.S_ID,Sname

 

12.查询姓“李”的老师的个数;

select count(distinct(Tname)) from Teacher where Tname like '李%';

 

13.查询所有课程成绩小于60分的同学的学号、姓名;

select S_ID,Sname from Student where S_ID not in (select S.S_ID from Student AS S,SC where S.S_ID=SC.S_ID and score>60);

14.查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名;

select distinct S_ID,Sname from Student,SC where Student.S_ID=SC.S_ID and SC.C_ID in (select C_ID from SC where S_ID='1001');

posted @ 2020-12-31 12:12  🍊爱吃橙子的丸子  阅读(105)  评论(0编辑  收藏  举报