Hi. I need help with my QueryString.... "SELECT fbid, points, time, pic, name FROM `myTable` WHERE country='de' ORDER BY points DESC, time ASC LIMIT 10" Code (markup): My Problem is that fbid results should be unique with best points (points DESC) and best time (time ASC). With "SELECT DISTINCT fbid, points.... " i get double "fbid's" too.? How can solve this?
Try: "SELECT fbid, points, time, pic, name FROM `myTable` WHERE country='de' GROUP BY fbid ORDER BY points DESC, time ASC LIMIT 10"
jestep's query is exactly what you asked for, but not what I think you want. Try and put into plain words what you are trying to get out--don't use field names, don't use SQL terms, just plain words. Here's a plain language statement of what I think you want: >> The lowest time and highest score for each individual. If that's correct, here's the query to do it: SELECT fbid, MAX(points) AS bestpoints, MIN(time) AS besttime, name FROM myTable WHERE country='de' ORDER BY MAX(points) DESC, MIN(time) ASC LIMIT10; PHP: If not, correct my plain language statement to make it say what you want.