现有下表字段的数据表video,记录不同类型的每个视频在每天的播放量。
现在要查询每个类型下,4月总播放量前N的视频。
尝试通过以下嵌套子查询完成,但是row_number这里一直报错
求大佬解答。
select *
(select *,row_number() over(partition by type order by play_total des) as rankid
from (select id,type,sum(play_daily) as play_total
from video
where substr(date, 1, 6) = '202004'
group by id,type) a
)b
where rankid <= N