I have a table like this
Event ID | Contract ID | Event date | Amount | ---------------------------------------------- 1 | 1 | 2009-01-01 | 100 | 2 | 1 | 2009-01-02 | 20 | 3 | 1 | 2009-01-03 | 50 | 4 | 2 | 2009-01-01 | 80 | 5 | 2 | 2009-01-04 | 30 |
For each contract I need to fetch the latest event and amount associated with the event and get something like this
Event ID | Contract ID | Event date | Amount | ---------------------------------------------- 3 | 1 | 2009-01-03 | 50 | 5 | 2 | 2009-01-04 | 30 |
I can't figure out how to group the data correctly. Any ideas?
Thanks in advance.