您好,欢迎访问一九零五行业门户网

SQL查询排序有关问题

sql查询排序问题
select * , group_concat( ' ' , concat_ws( ' x ', `sku` , `quantity-purchased` ) , ' ' ),group_concat(' ' , `order_id` , ' ') from ( select * from `sale_orders` order by `sku`) t where `shipments` =0 and `number` =$id group by `recipient-name` , `ship-address-1` order by `sku`
以下为查询的结果:
ship name sku-quantity
001-01 wang a0015-00-04-23 x 1  
002-02 liu a0041-00-ww-25 x 1 , a0042-00-ac-25 x 1  
003-03 li a0041-00-ww-25 x 1 , a0042-00-ac-25 x 1 , a0256-00-o6-34 x 1 
004-04 fang a0041-00-ww-25 x 1 ,a0042-00-ac-25 x 1 , a0217-00-si-33 x 1
请问怎么在此基础上再按sku-quantity字段的sku个数来排序(就是字符串长度)
------解决方案--------------------
试试 ..... order by count(sku)
------解决方案--------------------
你这个group_concat( ' ' , concat_ws( ' x ', `sku` , `quantity-purchased` ) , ' ' ),group_concat(' ' , `order_id` , ' ')
两个group_concat, 
和你的结果
ship name sku-quantity
001-01 wang a0015-00-04-23 x 1
002-02 liu a0041-00-ww-25 x 1 , a0042-00-ac-25 x 1
里怎么对应?
哪个是shu-quantity?
其它类似信息

推荐信息