select courseno,stuno,avg(score) ‘平均分最高值‘--这里是求平均,后面的条件是过滤最大值的 from tablename group by courseno,stuno having avg(score) >= all (select avg(score) sco--这里是过滤最大值 from tablename group by courseno)
select top 1 with ties courseno,avg(score) ‘平均分最高值‘--这里的with ties 就是为了解决相同排名的,找出排列相同的值
from tablename
group by courseno
order by 平均分最高值 desc
原文:http://www.cnblogs.com/wdpnodecodes/p/7406269.html