StandaLepi StandaLepi - 29 days ago 10
MySQL Question

mysql select max group by id

good evening,
i have a table:

A B C
45 1 1
22 2 1
40 3 1
43 1 2
21 2 2
61 3 2
49 4 2
60 5 2
76 1 3
41 2 3
57 3 3


i find
max(A)
from
max(B)
group by
C
. The result should be 60 - max number in
A
from last row in
B
from each group (
C
)
Thank you for your help

Answer Source

If i understand correctly your question you could use an inner join on select max(b):

select max(A)
from my_table m
inner  join (
    select C, 
           max(B) act_B
    from my_table  
    group by C
) t on t.act_B =  m.B and t.c = m.c