"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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php