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
 General SQL Server Forums
 New to SQL Server Programming
 Need solution - query to fetch latest record

Author  Topic 

Aditya_gupt
Starting Member

1 Post

Posted - 2012-06-29 : 14:29:05
Hi All,

Need your help in finding the solution for the below requirement:

Table has details like below:

NAME UPATE-TIMESTAMP
==== ===============
mary time1
mary time2
mary time3
tom time1
tom time2
tom time3
tom time4
richard time1
richard time2

Output Expected:

NAME UPATE-TIMESTAMP
==== ===============
mary time3 - this time should be max for all records related to mary i.e. latest time.
tom time4 - this time should be max for all records related to tom i.e. latest time.
richard time2 - this time should be max for all records related to richard i.e. latest time.

In summary, the requirement is to fetch the latest upated record for each unique NAME.

Thanks in advance.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-06-29 : 15:01:18
SELECT NAME, MAX(UPATE-TIMESTAMP) UPATE-TIMESTAMP
FROM myTable
GROUP BY NAME
Go to Top of Page
   

- Advertisement -