id year category_id rating avg_better
需要帮助找到所有更好产品的平均评分
答案 0 :(得分:0)
select *,
( select avg(rating)
from mytab as t2
where t2.year = t1.year -- same year
and t2.rating > t1.rating -- better rating
) as avg_better
from mytab as t1