Skip to content
Advertisement

How I can integrate two function in the same request

1

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:

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
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement