Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要显示销量最高的月份。我不知道该怎么做。请帮忙谢谢。我有:
id、prod_name、价格、q_sold、月份
q_sold 必须与输入的月份数相加。
您可以按总和排序您的结果,并且只取第一个条目limit 1
limit 1
select `month`, sum(q_sold) as sold_sum from your_table group by `month` order by sold_sum desc limit 1