How to get max values when you group MySQL?

The query without grouping gives such a result. Left right id number.
VLFY1sKpfgg.jpg

If you group BY GROUP id the number of hits the maximum in the result. Sort before grouping don't know how because the ORDER BY should come after GROUP BY, and it already receives the minimum values and singular.

UP:
SELECT table1.id, table2.members
FROM table1
INNER JOIN table2 ON table2.id = table1.id WHERE table2.members > 400 GROUP BY id

The desired entry with the maximum value among members but only those records where the members > 400
July 2nd 19 at 13:34
2 answers
July 2nd 19 at 13:36
Solution
Aggregate functions - MAX()
Yes, I understand, but do not understand how to use it updated the question - Tyreek.Stoke commented on July 2nd 19 at 13:39
Either
SELECT `id`, MAX(`members`) AS `max_members`
 FROM `table`
 WHERE `members` > 400
 GROUP BY `id`

either
SELECT `id`, MAX(`members`) AS `max_members`
 FROM `table`
 GROUP BY `id`
 HAVING `max_members` > 400
- Kenyatta commented on July 2nd 19 at 13:42
July 2nd 19 at 13:38
Solution
select id, max(quantity) from some_table group by id;
Updated the question, put the query that works now. I guess that you MAX() to use but how to insert MAX after the WHERE clause? Need maximum one entry but only among those that > 400 I Have every syntactic climbs... - Tyreek.Stoke commented on July 2nd 19 at 13:41
:
select table1.id, max(table2.members) from table1 inner join table2 using(id) group by id having max(table2.members) > 400;
- Kenyatta commented on July 2nd 19 at 13:44

Find more questions by tags MySQLSQL