Given a data set similar to this:
ccy | time | fxrate
GBP | 11 | 1.2
EUR | 21 | 1.4
CHF | 9 | 3.1
GBP | 15 | 1.1
EUR | 20 | 1.5
CHF | 1 | 3.0
CHF | 7 | 3.0
GBP | 20 | 1.9
I want to get the latest fxrates (by 'time') for each ccy:
ccy | time | fxrate
GBP | 20 | 1.9
EUR | 21 | 1.4
CHF | 9 | 3.1
Is it possible to get this data with a single sql query? My skills are failing me. I assume I need to GROUP BY ccy..? where max(time) ..? LIMIT 1 ..? Help!
[EDIT] using postgresql