Get MAX from a GROUP BY

后端 未结 5 1444
礼貌的吻别
礼貌的吻别 2021-02-09 04:38

I was practicing some SQL when this hit me. I wanted to see how many times a certain commodity came up and from there get the commodity which came up the most.

5条回答
  •  無奈伤痛
    2021-02-09 05:32

    Try this query

      SELECT commodity,COUNT(commodity) AS count 
        FROM orders
    GROUP BY commodity
    ORDER BY count desc
       LIMIT 1;
    

提交回复
热议问题