当前位置: 代码迷 >> PHP >> 新手!查询语句
  详细解决方案

新手!查询语句

热度:328   发布时间:2012-03-26 15:46:56.0
新手求助!查询语句
表A里有字段 id(自增),order_id(订单id),goods_sn(产品编码),其他字段... 查询产品编码出现最多的前10个产品的语句怎么写呀?菜鸟求助

------解决方案--------------------
SQL code


SELECT *, count(goods_sn) as counter FROM table group by goods_sn order by goods_sn desc

------解决方案--------------------

SELECT COUNT(*) AS CT FROM A ORDER BY id DESC GROUP BY goods_sn;

试看看

------解决方案--------------------
SQL code

    SELECT count(*) as counter FROM table group by goods_sn order by goods_sn desc limit 10 
  相关解决方案