要取top10品牌,各品牌的top10渠道,各品牌的top10渠道中各渠道的top10档期
1、取top10品牌
select “品牌” , sum/count/其他() as num from "table_name" order by num desc limit 10;
2、取top10品牌下各品牌的top10渠道
select a.* from (select "品牌","渠道",sum/count() as num, row_number () over (partition by "品牌" order by num desc) rank from “table_name” where 品牌限制条件 group by “品牌”,“渠道” ) a having a.rank <= 10;
3、 取top10品牌下各品牌的top10渠道中各渠道的top10档期
select a.* from (select "品牌","渠道","档期",sum/count/其他() as num row_number() over (partition by "档期" order by num desc) rank from "table_name" where 品牌限制条件 group by “品牌”,“渠道) a Having a.rank <= 10;
联系客服