ѧÉú³É¼¨¹ÜÀíÊý¾Ý¿â

select count( distinct Sno) as ѧÉúÈËÊý from Grade where Cno=(select Cno from Course where Cname='Êý¾Ý¿â') ÔÚÏÂÃæ´°¿ÚÏÔʾ²éѯ½á¹ûÈçÏÂͼ3-15Ëùʾ¡£

ͼ3-15

8) ÕÒ³öijÄ꼶ij°à³É¼¨Îª¿ÕµÄѧÉúÐÕÃû

ÕÒ³ö°à¼¶ºÅΪ¡°00314¡±µÄѧÉú³É¼¨Îª¿ÕµÄÐÕÃû¡£ ÊäÈësqlΪ£º

select Sname as ÐÕÃû from Student where Clno='00314' and Sno NOT in (select Sno from Grade where Clno='00314') ÔÚÏÂÃæ´°¿ÚÏÔʾ²éѯ½á¹ûÈçÏÂͼ3-16Ëùʾ¡£

µÚ 33 Ò³ ¹² 50 Ò³

ͼ3-16

3. ÒÀ¾ÝÉÏÊöµÄËĸö±í£¬ÓÃSELECTǶÌײéѯ£¨×Ó²éѯ£©Íê³ÉÈçϲéѯ 1) ÕÒ³öÓëijͬѧÔÚͬһ¸ö°àµÄͬѧ£» ÕÒ³öÓë¡°Áõɽ¡±Í¬Ñ§ÔÚÒ»¸ö°àµÄͬѧ¡£ ÊäÈësqlΪ£º

select Sname as ÐÕÃû from Student where Clno=(select Clno from Student where Sname='Áõɽ') and Sname!='Áõɽ' ÔÚÏÂÃæ´°¿ÚÏÔʾ²éѯ½á¹ûÈçÏÂͼ3-1£·Ëùʾ¡£

µÚ 34 Ò³ ¹² 50 Ò³

ͼ3-17

2) ÕÒ³öËùÓÐÓëijͬѧÓÐÏàͬµÄÑ¡Ð޿γ̵ÄѧÉúÐÅÏ¢£» ÕÒ³öËùÓÐÓë¡°ÀîÓá±Í¬Ñ§ÓÐÏàͬµÄÑ¡Ð޿γ̵ÄѧÉúÐÅÏ¢¡£ ÊäÈëµÄsqlÓï¾äÈçÏ£º

select * from student where Sname !='ÀîÓÃ' and Sno in (select Sno from Grade where Cno in (select Cno from Grade where Sno=(select Sno from student where Sname='ÀîÓÃ'))) ÔÚÏÂÃæ´°¿ÚÏÔʾ²éѯ½á¹ûÈçÏÂͼ3-18Ëùʾ¡£

ͼ3-18

µÚ 35 Ò³ ¹² 50 Ò³

3) ÕÒ³öÄêÁäÔÚ23ºÍ25Ö®¼äµÄѧÉúÐÅÏ¢£» ÊäÈësqlÓï¾äΪ£º

select * from student where Sage>=23 and Sage<=25 ÔÚÏÂÃæ´°¿ÚÏÔʾ²éѯ½á¹ûÈçÏÂͼ3-19Ëùʾ¡£

ͼ3-19

4) ÕÒ³öÑ¡ÐÞÁËij¿Î³ÌµÄѧÉúѧºÅºÍÐÕÃû£» ÕÒ³öÑ¡ÐÞÁË¡°Êý¾Ý¿â¡±¿Î³ÌµÄѧÉúѧºÅºÍÐÕÃû¡£ ÊäÈëµÄsqlÓï¾äΪ£º

select Sno,Sname from Student where Sno in (select Sno from Grade where Cno =(select Cno from Course where Cname='Êý¾Ý¿â')) ÔÚÏÂÃæ´°¿ÚÏÔʾ²éѯ½á¹ûÈçÏÂͼ3-20Ëùʾ¡£

µÚ 36 Ò³ ¹² 50 Ò³

ÁªÏµ¿Í·þ£º779662525#qq.com(#Ìæ»»Îª@)