riverpast
03-14-2007, 02:34 PM
This works:
select product_id, count(*) from order_line group by product_id
It shows the product and how many sales each product has.
However, I want to sort by the product sales, so I am trying:
select product_id, count(*) from order_line group by product_id order by count(*)
It doesn't like "order by count(*)". I tried many variations and just couldn't figure out how to make it sort by the count
Of course, "orber by product_id" would work.
How do I make it sort by the COUNT()?
By the way, I am using MySQL
select product_id, count(*) from order_line group by product_id
It shows the product and how many sales each product has.
However, I want to sort by the product sales, so I am trying:
select product_id, count(*) from order_line group by product_id order by count(*)
It doesn't like "order by count(*)". I tried many variations and just couldn't figure out how to make it sort by the count
Of course, "orber by product_id" would work.
How do I make it sort by the COUNT()?
By the way, I am using MySQL
