Posted by Yuanyuan, Feb. 28, 2022, 3:01 p.m.
#109 Why my query is wrong
with pop_product_category as(
select product_category_id,
dense_rank(product_category_id)over(order by count(order_id) desc)ranking
from orders O
inner join product_category PC
on PC.product_id = O.product_id
group by product_category_id)
select product_category_id, ranking
from pop_product_category
group by product_category_id
limit 3
select product_category_id,
dense_rank(product_category_id)over(order by count(order_id) desc)ranking
from orders O
inner join product_category PC
on PC.product_id = O.product_id
group by product_category_id)
select product_category_id, ranking
from pop_product_category
group by product_category_id
limit 3