vearns Posted January 8, 2009 Share Posted January 8, 2009 Hello, i need help for ranking order. currently i used this SQL statement to generate a descending result : SELECT name, COUNT( customerid ) AS orderCount FROM contest GROUP BY name ORDER BY orderCount DESC Let say the descending result is : John 5 Tom 4 Mark 3 Jane 2 Vivian 1 i want to output : Mark is on the 3rd out of 5th. how to do it in MySQL and PHP ? Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/ Share on other sites More sharing options...
vearns Posted January 8, 2009 Author Share Posted January 8, 2009 let say the descending result is : John 64735 Tom 5774 Mark 3533 Jane 211 Vivian 12 how to make mysql know that Mark is the 3rd highest and Tom is the second highest ? is there any other way to solve this ? Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/#findComment-732402 Share on other sites More sharing options...
abdfahim Posted January 8, 2009 Share Posted January 8, 2009 You mean you need to return the result of the 3rd highest scorer? then SELECT name, COUNT( customerid ) AS orderCount FROM contest GROUP BY name ORDER BY orderCount DESC LIMIT 2,2 Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/#findComment-732447 Share on other sites More sharing options...
fenway Posted January 8, 2009 Share Posted January 8, 2009 Since you're outputting all the results anyway, use a php counter. Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/#findComment-732511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.