shocker-z Posted May 30, 2007 Share Posted May 30, 2007 Hi, I'm at a dead brainer again! What i need to do is select the top 5 client who have the most reccords in my database so im guessing im going to have to group them to return how many clients are selected. i was thinking somthing like SELECT client FROM pronet WHERE logged BETWEEN '$monthstart' AND '$monthend' GROUP BY client LIMIT 5 would work but it's not returning the top 5 highest.. also i could do with retuirning the number of calls in the database too. Regards Liam Link to comment https://forums.phpfreaks.com/topic/53639-select-top-5-clients-with-most-calls-logged/ Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 SELECT COUNT(client) as ClientCount, client FROM pronet WHERE logged BETWEEN '$monthstart' AND '$monthend' GROUP BY client ORDER BY ClientCount LIMIT 5 Untested and not sure if it will work, but give it a shot. Link to comment https://forums.phpfreaks.com/topic/53639-select-top-5-clients-with-most-calls-logged/#findComment-265157 Share on other sites More sharing options...
shocker-z Posted May 30, 2007 Author Share Posted May 30, 2007 $gettoploggedclients=mysql_query("SELECT client, count(*) as `clientcount` FROM pronet WHERE logged BETWEEN '$monthstart' AND '$monthend' GROUP BY client ORDER BY clientcount DESC LIMIT 5") or die('Error getting top logged clients: '.mysql_error()); that works just figured it myself thanks anyway mate Link to comment https://forums.phpfreaks.com/topic/53639-select-top-5-clients-with-most-calls-logged/#findComment-265159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.