Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How do I get latest updated record???

Author  Topic 

adam3291
Starting Member

8 Posts

Posted - 2002-11-07 : 16:26:21
Because of name changes I have multiple records for the same employee in my table. I went to retrieve the last changed record. The only column I have that may be of help is LastChangedDate. Is there a way to retrieve a record from this table where the last changed date is the most current? I would appreciate any help.

THANK YOU!!!!!!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2002-11-07 : 16:31:17
This should do it for you:

SELECT MAX(LastChangedDate)
FROM Table1
WHERE Last_name = 'Smith' and First_name = 'John'

Just change the table name and the where clause to get the correct record.




Edited by - tduggan on 11/07/2002 16:32:06
Go to Top of Page

r937
Posting Yak Master

112 Posts

Posted - 2002-11-07 : 19:23:06
if there's more than one employee with multiple records, use a correlated subquery

select EmployeePK, Firstname, Lastname
, LastChangedDate
from yourtable A
where LastChangedDate =
( select max(LastChangedDate)
from yourtable
where EmployeePK = A.EmployeePK )


rudy
Go to Top of Page
   

- Advertisement -