I want to get those Product in ascending order who number is greater in mysql
order_id | product_id
1 | 13
1 | 12
1 | 24
2 | 14
2 | 245
2 | 23
3 | 14
3 | 23
4 | 14
i have done that code but its not working
SELECT product_id FROM `sales_order_item` ORDER BY COUNT('product_id') ASC
i want priduct_id in ascending order on the basis of there count\\
product_id
14
23
13
24
245
as 14 occurs 4 times it must have to be on top and so on
use order by COUNT('product_id') desc
SELECT product_id,COUNT('product_id') as cnt FROM `sales_order_item`
group by product_id
ORDER BY cnt desc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.