Re: count() and grouping
| From: | user at domain dot invalid | Date: | Wed, 07 Aug 2002 00:02:23 +0000 |
| Subject: | Re: count() and grouping | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21029@lists.php.net to get a copy of this message | ||
I believe your problem lies in your GROUP BY. Try removing that and then add your ORDER BY Count(*).
ie SELECT submitted_by, COUNT(*) FROM articles ORDER BY COUNT(*)
make certain you are using the Aggregate Function ' COUNT ' correctly as well.
hope this helps
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