写一下开窗的题解:
1.先按job使用avg函数开窗
select
id,
job,
score,
avg(score) over(partition by job) as avg
from
grade2.根据开窗结果,按条件选择分数大于由1开窗得到的平均分数,完整代码
select
id,
job,
score
from (
select
id,
job,
score,
avg(score) over(partition by job) as avg
from
grade
) as avg_score
where
score > avg


京公网安备 11010502036488号