Sorry for the nondescript title. I\'ll edit as we go along.
I have a table RateTable:
| Code | Date | Rate |
B001 2009-
I would advise, if you have control over this at this point, to only right bookended data. In other words, only write a record to the table when the rate changes. You can then assume that any data between the changes will have stayed the same. This will greatly reduce the amount of data you need to store.
That said, this query, or something close, aught to accomplish what you're asking for:
select rt.Code, MIN(rt.Date), rt.Rate
from RateTable rt
group by rt.Code, rt.Rate
edit: sorry, change max to min