Can I run a select statement and get the row number if the items are sorted?
I have a table like this:
mysql> describe orders; +-------------+----
Take a look at this.
Change your query to:
SET @rank=0; SELECT @rank:=@rank+1 AS rank, itemID, COUNT(*) as ordercount FROM orders GROUP BY itemID ORDER BY ordercount DESC; SELECT @rank;
The last select is your count.