题解 | #考试分数(二)#

考试分数(二)

http://www.nowcoder.com/practice/f456dedf88a64f169aadd648491a27c1

select id,job,score
from grade g1
where score>(select avg(score)as avg
             from grade g2
             where g1.job=g2.job
             group by g2.job)
order by id;

#一.计算各job的平均得分 select avg(score)as avg from grade g2 group by g2.job 二.用关联子查询取出各job的分数大于平均值的行 select id,job,score from grade g1 where score>(select avg(score)as avg from grade g2 where g1.job=g2.job group by g2.job) order by id; *这里注意关联条件g1.job=g2.job写在子查询里,该条件的意思是:在同一job种类下对各分数和平均分数进行比较。

全部评论

相关推荐

牛客765689665号:没有实习是硬伤,央国企看学历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务