Here is a small code snippet for getting the recent records from the table.
drop table VENKAT_TABLE
go
create table Venkat_Table(code varchar(100),rate decimal(10,8),date1 date)
go
insert into VENKAT_TABLE values ('sam', 1.240000, '01/08/2004')
insert into VENKAT_TABLE values ('sam', 1.840000, '02/08/2004')
insert into VENKAT_TABLE values ('pal', 1.240000, '01/08/2005')
insert into VENKAT_TABLE values ('pal', 0.840000, '10/08/2003')
select code,rate,date1 from
(
select ROW_NUMBER() over (partition by code order by date1) as rank1,*
from VENKAT_TABLE ) t
where rank1=1
Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

mohan kumarPosted May 7, 2012, 1:42 PM
I can't get the exact output. All records are not in the expected Order :)
mohan kumarPosted May 7, 2012, 1:42 PM
I can't get the exact output. All records are not in the expected Order :)