mysql - SQL, know last value saved on a table of a few parameters -
i have table like:
+----------+--------------+---------+ | name | date | value | +----------+--------------+---------+ | | 2015-06-01 | 32 | | b | 2015-06-01 | 33 | | c | 2015-06-01 | 34 | | | 2015-06-03 | 24 | | | 2015-06-02 | 30 | | b | 2015-06-05 | 45 | | b | 2015-06-02 | 65 | | | 2015-05-29 | 31 | | | 2015-05-28 | 57 | | c | 2015-06-02 | 58 | +----------+--------------+---------+
i need mysql query returns me:
+----------+---------+ | name | value | +----------+---------+ | | 24 | | b | 45 | +----------+---------+
it means, query has return specific name (a & b in example) last value (more recent date) saved name ( on 3d june 24 , b on 5th june 45).
is possible?
thanks.
this should give desired result
select b.name, (select value mytable a.name = b.name order date desc limit 1) mytable b -- b.name in ('a', 'b') group b.name
Comments
Post a Comment