RE: [PHP-DB] count() and grouping

From: Date: Tue, 06 Aug 2002 22:24:21 +0000
Subject: RE: [PHP-DB] count() and grouping
Groups: php.db 
Request: Send a blank email to php-db+get-21025@lists.php.net to get a copy of this message
ooops... :-) SELECT submitted_by, COUNT(*) as CNT FROM articles GROUP BY submitted_by order by CNT DESC -----Original Message----- From: Ryan Jameson (USA) Sent: Tuesday, August 06, 2002 4:24 PM To: php-db@lists.php.net Subject: RE: [PHP-DB] count() and grouping SELECT submitted_by, COUNT(*) as CNT FROM articles GROUP BY submitted_by order by CNT -----Original Message----- From: tux [mailto:tuxen@gimped.net] Sent: Wednesday, August 07, 2002 6:22 AM To: php-db@lists.php.net Subject: [PHP-DB] count() and grouping 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#21025) next »