php - select the database, getting all the maximum values of a column -
i have following table:
id | value | data | v 1 | val1 | dat1 | 1 2 | val1 | dat2 | 2 3 | val1 | dat3 | 3 4 | val2 | dat4 | 1
what grab data
, each value
, has higher v
. no mean .. sorry english
sql output like:
id | value | data | v 3 | val1 | dat3 | 3 4 | val2 | dat4 | 1
thanks!
you need identify max value in subquery , join against constant element
fiddle
select * table1 join (select max(v) maxv, value table1 group value) t on t.maxv = table1.v , t.value=table1.value
Comments
Post a Comment