需求
统计每小时内host网址的topN
解答
步骤一:对每个小时内的来访host次数倒序排序标号
select ref_host,pv_ref_host_hour,concat(month,day,hour),row_number() over (partition by concat(month,day,hour) order by pv_ref_host_hour desc) as od from pvs_ref_host_hour;
步骤二:求Top3
select ref_host,pv_ref_host_hour,concat(month,day,hour),row_number() over (partition by concat(month,day,hour) order by pv_ref_host_hour desc) as od from pvs_ref_host_hour where od <= 3;