metalpain Posted October 11, 2008 Share Posted October 11, 2008 i would like to filter some results by the top 3 results but i would like to include instances where a result may have the sane value for example a.1, b.2 . c.1, d.3, e.4 so what i would like to do is have a.1, c.1, b.2, d.3 as my final result. Quote Link to comment https://forums.phpfreaks.com/topic/127945-filtering-results-by-top-results/ Share on other sites More sharing options...
Barand Posted October 11, 2008 Share Posted October 11, 2008 try something like SELECT username, score FROM user a WHERE EXISTS (SELECT COUNT(DISTINCT score) as x FROM user b WHERE b.score < a.score HAVING x < 3) ORDER BY `score` Quote Link to comment https://forums.phpfreaks.com/topic/127945-filtering-results-by-top-results/#findComment-662607 Share on other sites More sharing options...
scooby545 Posted November 26, 2009 Share Posted November 26, 2009 i believe this is a simular query to what im trying to do my data is in an sql table as follows : table name : searches search_word, date, time every time a user searches using the site a new row is added to the searches table. I want to pull out the top 10 searches from the table. Am i on the right track here ? cheers scooby Quote Link to comment https://forums.phpfreaks.com/topic/127945-filtering-results-by-top-results/#findComment-965983 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.