[Solved] SELECT * FROM people WHERE user_id=’$user_id’ ORDER BY time GROUP BY surname [closed]

[ad_1] The ORDER BY clause should be the last, but you have to specify fields to be aggregated. Such as: SELECT surname, count(*) FROM people WHERE user_token=’$user_token’ GROUP BY surname ORDER BY surname 1 [ad_2] solved SELECT * FROM people WHERE user_id=’$user_id’ ORDER BY time GROUP BY surname [closed]

[Solved] mySQL Largest number by group

[ad_1] In general ORDER BY in a sub-query makes no sense. (It only does when combined with FETCH FIRST/LIMIT/TOP etc.) The solution is to use a correlated sub-query to find the heaviest fish for the “main query”‘s current row’s username, location, species combination. If it’s a tie, both rows will be returned. SELECT * FROM … Read more