RE: [PHP-DB] SQL query...

From: Date: Thu, 15 Jan 2004 11:17:19 +0000
Subject: RE: [PHP-DB] SQL query...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-32404@lists.php.net to get a copy of this message
"SELECT DISTINCT(file_name), Count(file_name) FROM $table_name WHERE date BETWEEN '2003-10-01' AND '2003-12-31' group by file_name order by ??????? desc" In the above sql statement, I'm trying to achieve: 1. select all file names, between two dates. 2. list them, and order by the highest number of occurences of count() Basically, it's for a download tool we have, and my boss wants to easily be able to see the top downloaded files. It all works, but not the 'order by' bit... what do I have to order by... it's not 'file_name', and 'order by count(file_name0' causes an error... thoughts? Cheers, Tris... ----------------------------------------- can you not do this? "SELECT DISTINCT(file_name), Count(file_name)fcount FROM $table_name WHERE date BETWEEN '2003-10-01' AND '2003-12-31' group by file_name order by fcount desc" Please note that I have named count(file_name) fcount in the sql statement Hope this helps? Brett

« previous php.db (#32404) next »