=Teacher.T# and Teacher.Tname='Ҷƽ' and SC.score=(select max(score)from SC where C#=C.C# );
41¡¢²éѯ¸÷¸ö¿Î³Ì¼°ÏàÓ¦µÄÑ¡ÐÞÈËÊý
select count(*) from sc group by C#;
42¡¢²éѯ²»Í¬¿Î³Ì³É¼¨ÏàͬµÄѧÉúµÄѧºÅ¡¢¿Î³ÌºÅ¡¢Ñ§Éú³É¼¨
select distinct A.S#,B.score from SC A ,SC B where A.Score=B.Score and A.C# <>B.C# ;
43¡¢²éѯÿÃŹ¦³É¼¨×îºÃµÄǰÁ½Ãû
SELECT t1.S# as ѧÉúID,t1.C# as ¿Î³ÌID,Score as ·ÖÊý
FROM SC t1
WHERE score IN (SELECT TOP 2 score
FROM SC
WHERE t1.C#= C#
ORDER BY score DESC
)
ORDER BY t1.C#;
44¡¢Í³¼ÆÃ¿Ãſγ̵ÄѧÉúÑ¡ÐÞÈËÊý£¨³¬¹ý10È˵Ŀγ̲Åͳ¼Æ£©¡£ÒªÇóÊä³ö¿Î³ÌºÅºÍÑ¡ÐÞÈËÊý£¬²éѯ½á¹û°´ÈËÊý½µÐòÅÅÁУ¬²éѯ½á¹û°´ÈËÊý½µÐòÅÅÁУ¬ÈôÈËÊýÏàͬ£¬°´¿Î³ÌºÅÉýÐòÅÅÁÐ
select C# as ¿Î³ÌºÅ,count(*) as ÈËÊý
from sc
group by C#
order by count(*) desc,c#
45¡¢¼ìË÷ÖÁÉÙÑ¡ÐÞÁ½Ãſγ̵ÄѧÉúѧºÅ
select S#
from sc
group by s#
having count(*) > = 2
46¡¢²éѯȫ²¿Ñ§Éú¶¼Ñ¡Ð޵Ŀγ̵Ŀγ̺źͿγÌÃû
select C#,Cname
from Course
where C# in (select c# from sc group by c#)
47¡¢²éѯûѧ¹ý¡°Ò¶Æ½¡±ÀÏʦ½²ÊÚµÄÈÎÒ»Ãſγ̵ÄѧÉúÐÕÃû
select Sname from Student where S# not in (select S# from Course,Teacher,SC where Course.T#=Teacher.T# and SC.C#=course.C# and Tname='Ҷƽ');
48¡¢²éѯÁ½ÃÅÒÔÉϲ»¼°¸ñ¿Î³ÌµÄͬѧµÄѧºÅ¼°Æäƽ¾ù³É¼¨
select S#,avg(isnull(score,0)) from SC where S# in (select S# from SC where score <60 group by S# having count(*)>2)group by S#;
49¡¢¼ìË÷¡°004¡±¿Î³Ì·ÖÊýСÓÚ60£¬°´·ÖÊý½µÐòÅÅÁеÄͬѧѧºÅ
select S# from SC where C#='004'and score <60 order by score desc;
50¡¢É¾³ý¡°002¡±Í¬Ñ§µÄ¡°001¡±¿Î³ÌµÄ³É¼¨
delete from Sc where S#='001'and C#='001';
|