SELECT LAST(Rate_Of_Interest) FROM TABLE WHERE Loantype = 1.
What will retrieve the lastest rate of interest value for a given loantype.
But if you want to know the lastest, in the meaning of the last
EffectiveDate as I think you are trying to explain, you can simply do:
For a given loantype:
SELECT MAX(EffectiveDate)FROM TABLE WHERE Loantype = 1
For every one:
SELECT * FROM TABLE WHERE EffectiveDate = (SELECT MAX(DATE) FROM TABLE)
You will ned the effective date as column type date, so the string can be parsed (as date obviously)
You can also do a stored procedure so you can retrieve the present date (using
getDate) and get you can find the difference using
DATEDIFF.
More info
http://www.sql-server-performance.com/2007/datetime-2008/[
here]
Let me know if this helps you.