显示销售量最高的月份

时间:2022-01-24 15:06:23

I need to show the month with the highest number of quantity sold. I don't know how to do that. Please help thank you. I have:

我需要显示出售数量最多的月份。我不知道该怎么做。请帮忙谢谢。我有:

id, prod_name, price, q_sold, month

id,prod_name,price,q_sold,month

the q_sold must sum up with the number of month input.

q_sold必须与月输入的数量相加。

1 个解决方案

#1


3  

You can order your result by the sum and take only the first entry with limit 1

您可以按总和订购结果,并仅使用限制为1的第一个条目

select `month`, sum(q_sold) as sold_sum
from your_table
group by `month`
order by sold_sum desc
limit 1

#1


3  

You can order your result by the sum and take only the first entry with limit 1

您可以按总和订购结果,并仅使用限制为1的第一个条目

select `month`, sum(q_sold) as sold_sum
from your_table
group by `month`
order by sold_sum desc
limit 1