查詢“001”課程比“002”課程成績高的所有學生的學號;


 

select a.s_id from (select s_id,score from SC where C_ID='001') a,(select s_id,scorefrom SC where C_ID='002') b where a.score>b.score and a.s_id=b.s_id;

 

10.查詢平均成績大於60分的同學的學號和平均成績;

select S_ID,avg(score) from sc group by S_ID having avg(score) >60;

 

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');


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM