I have the following data:
id date_modified value
1 some_date 4
1 some_date 3
1 some_date 1
2 some_date 5
3 some_date 8
3 some_date 7
...
and this query gets the id and date_modified where date_modified is the latest date:
select bh.id, max(bh.date_modified)
from my_table bh
group by bh.id;
which does this:
id date_modified
1 some_date
2 some_date
3 some_date
...
where each date is the latest date for each id which is nearly what I want.
How do I change the group by to get the value out? It’s the value that I’m interested in but I need to group using the id.
Many thanks.
Try this: