I want to display the most ordered product with its name but I don’t know how to integrate the max and count function in the same request
Advertisement
Answer
here is how you can do it:
x
select * from products p
join (
select productid , sum(quantity) quantity
from orders
group by productid
) t on t.productid = p.productid
order by quantity desc