首頁 >後端開發 >php教程 >新手!查询语句

新手!查询语句

WBOY
WBOY原創
2016-06-13 10:07:01914瀏覽

新手求助!查询语句
表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<br><font color="#e78608">------解决方案--------------------</font><br><br>SELECT COUNT(*) AS CT FROM A ORDER  BY id  DESC GROUP BY goods_sn;<br><br>试看看<br><br><font color="#e78608">------解决方案--------------------</font><br>
SQL code
    SELECT count(*) as counter FROM table group by goods_sn order by goods_sn desc limit 10<div class="clear">
                 
              
              
        
            </div>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn