Page 1 of 1

Top Ten Results

Posted: Mon Nov 11, 2002 2:25 pm
by EricS
I'm trying to write a mysql command that will find the top ten, and only the top ten results from a search. Here is the code i tried:

Code: Select all

SELECT Name,NumberSold FROM PRODUCT ORDER BY NumberSold LIMIT 10
What I want is the top ten sold items, what Im getting is the first 10 items in that tables ordered by number of sold.

Also, I only want 10 returned if that's possible.

Thanks in advance.

Eric Stewart[/quote]

Posted: Mon Nov 11, 2002 3:29 pm
by kitsch
Try this:

Code: Select all

SELECT Name,NumberSold FROM PRODUCT ORDER BY NumberSold DESC LIMIT 10

How did I miss that

Posted: Mon Nov 11, 2002 8:19 pm
by EricS
Thanks, I hate making such stupid mistakes. :roll:

Worked great kitsch.

Eric Stewart