My table and data as following,declare @jobHistory table (jobHistoryID int, groupID int, Company varchar(100), Position varchar(100), startDte datetime) ;/*jobHistoryID is a Primary Key*/insert into @jobHistory values(1, 40, 'STATSCHIPPAC (M) SDN BHD', 'SENIOR TECHNICIAN', '19960308');insert into @jobHistory values(2, 12, 'Intel Product (M) Sdn Bhd', 'Engineer (Test Development)', '20050601');insert into @jobHistory values(3, 40, 'MAYFLOWER CAR RENTAL', 'ASSISSTANT OPERATION', '20050825');insert into @jobHistory values(4, 21, 'SHIN YANG TRADING', 'ACCOUNT ASSISTANT', '20070723');insert into @jobHistory values(5, 55, 'CITIGROUP', 'CUSTOMER SERVICE OFFICER', '20090112');insert into @jobHistory values(6, 12, 'Tyco Electronics (M) Sdn Bhd', 'Accounts Clerk', '19970925');
Looking for help to produce the record by latest date. In this case the latest date is startDteMy expected result shown as follow,jobHistoryID groupID Company Position startDte-----------------------------------------------------------------2 12 Intel Product (M) Sdn Bhd Engineer (Test Development) 2005-06-01 00:00:00.0003 40 MAYFLOWER CAR RENTAL ASSISSTANT OPERATION 2005-08-25 00:00:00.0004 21 SHIN YANG TRADING ACCOUNT ASSISTANT 2007-07-23 00:00:00.0005 55 CITIGROUP CUSTOMER SERVICE OFFICER 2009-01-12 00:00:00.000]