I have a table product with sample data as below
product 1 2 2 3 1
Quantity 10 15 20 10 5
I need to findout which product has highest quantity after summing up all the available quantity for all the products
Example: Here answer would be 15+20 = 35 is greatest so product 2 has more quantity
please help with query
select product, sum(quantity) as sum_quantity
from products
group by product
order by sum_quantity desc
limit 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.