BrainPill Posted September 13, 2019 Share Posted September 13, 2019 (edited) I have a query it goes like this: SELECT `person_id` , MAX(exam_score) FROM `results` GROUP BY `exam_score` exam_score is column and some values are double when using query above I get 1 result for each. So if the exam_score is 10, 8, 9 , 10, 8, 5, 3 10 , 6 it does: 10, 9, 8 , 6, 5, 3 while I would want: 10,10,10, 9, 8, 8 Edited September 13, 2019 by BrainPill Link to comment Share on other sites More sharing options...
justsomeguy Posted September 13, 2019 Share Posted September 13, 2019 Group by the person. Link to comment Share on other sites More sharing options...
BrainPill Posted September 14, 2019 Author Share Posted September 14, 2019 solved it by using ORDER BY person_id DESC LIMIT 6 Link to comment Share on other sites More sharing options...
BrainPill Posted September 14, 2019 Author Share Posted September 14, 2019 But I want this to be selected from the same table found in multiple databases. Anyone got a clue how to do this? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 16, 2019 Share Posted September 16, 2019 If you want to query multiple databases and group the results into a single result set, you need to use unions or subqueries to get the various results into a single set. Link to comment Share on other sites More sharing options...
Makwana Prahlad Posted January 28, 2020 Share Posted January 28, 2020 Hello,@BrainPill Please try this query, To select multiple rows with highest value : select * from updates where 1 group by matching having votes=max(votes) order by matching asc; I hope above query will be useful for you. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now