Re: count() and grouping
| From: | Dan Koken | Date: | Wed, 07 Aug 2002 01:24:57 +0000 |
| Subject: | Re: count() and grouping | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21032@lists.php.net to get a copy of this message | ||
SELECT submitted_by, COUNT(*) as cnt
FROM articles
GROUP BY submitted_by
ORDER by cnt desc
Tux wrote:
Hey guys, i have been trying to figure out how to do this but havent found anything positive, anyway here is the db query that im doing: SELECT submitted_by, COUNT(*) FROM articles GROUP BY submitted_by; now what this returns is something like submitted_by | count(*) ======================= andrew 12 ben 13 terry 30 however what i want it to do is display by the highest number first ie terry, ben, andrew, not show them in alphabetical order, this is so i can display a 'most submissions' type thing. ive tried using ORDER by count(*) desc and stuff like that but none of it seems to work?? any ideas greatly appreciated jo