SELECT *, group_concat ('', concat_ws ('X', 'sku ', 'quantity-purchased'),''), group_concat ('', 'order _ id': SQL query sorting problem
SELECT *, group_concat ('', concat_ws ('X', 'sku ', 'quantity-purchased'),''), group_concat ('', 'Order _ id ', '') FROM (select * from 'sale _ orders 'Order by 'sku ') t where 'shippings' = 0 AND 'number' = $ id group by 'reiient-name', 'ship-address-1 'Order BY 'SK'
The query results are as follows:
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
On this basis, how can I sort by the number of sku in the SKU-quantity field (that is, the string length)
------ Solution --------------------
Try... order by count (sku)
------ Solution --------------------
Group_concat ('', concat_ws ('X', 'sku ', 'quantity-purchased'),''), group_concat ('', 'Order _ id ', '')
Two group_concat,
And your results
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
How is it matched?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service