Hi everyone,
I'm new to mySQL. I have a table like this one:
+-------+-------+-------+
| date | plant | value |
+-------+-------+-------+
| date1 | 1 | 10 |
| date2 | 1 | 12 |
| date3 | 1 | 15 |
| date4 | 2 | 30 |
| date5 | 2 | 34 |
| date3 | 2 | 43 |
+-------+-------+-------+
The result I want is "the last (more recent) value for each plant". I mean
+-------+-------+-------+
| date | plant | value |
+-------+-------+-------+
| date3 | 1 | 15 |
| date5 | 2 | 34 |
+-------+-------+-------+
I tried as follows:
select max(date), plant, ?value?
from table_name
group by plant;
The problem, I know, is on the 'value' column. How can I return the the proper value?
Thank you.