Get Recent records from the table
Blog author: Jvprabhusanthi | Posted on: 5/4/2012 | Category: SQL Server Blogs | Views: 616 | Status: [Member] | Points: 75
| Alert Moderator
Here is a small code snippet for getting the recent records from the table. drop table VENKAT_TABLEgocreate table Venkat_Table(code varchar(100),rate decimal(10,8),date1 date)goinsert 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 .JHead, KaaShiv InfoTech Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
http://kaashivinfotech.com/Ebooks.aspx
Found interesting? Add this to:
|