Sign-up....

面试题:如下的sql该怎么写?

有一张表Table(Sid,Sco,Score),分别为学号,课程号,成绩.要查询每门课程的平均成绩并降序排列.要是平均成绩相等的,则按照学号的升序排列.

[79 byte] By [msdn] at [2007-9-26 8:20:43]
# 1 Re: 面试题:如下的sql该怎么写?

select Sco,avg(Score) from Table group by Sco order by avg(Score) desc,Sid asc

lee_billiy at 2005-5-26 22:36:08 >
# 2 Re: 面试题:如下的sql该怎么写?

select distinct sid,average(score) as b from table group by sid order by b,sid

bill9 at 2005-5-26 22:43:35 >
# 3 Re: 面试题:如下的sql该怎么写?

select distinct sid,average(score) as b from table group by sid order by b desc,sid

bill9 at 2005-5-26 22:44:33 >

Oracle

All Classified