select
p.name as product_name,
sum(o.quantity) as total_sales,
row_number() over(partition by p.category order by sum(quantity) desc) as category_rank
from orders as o
join products as p on o.product_id = p.product_id
group by o.product_id, p.category
order by p.category asc, total_sales desc, o.product_id asc
第5行,quantity改成o.quantity就会报错,不知道咋回事



京公网安备 11010502036488号