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 2005 Forums
 Transact-SQL (2005)
 Selecting records with latest date

Author  Topic 

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2008-12-03 : 15:06:27
I have a table with User and DateCreated, it is possible that the user have been inserted multiple times, how to do I select the records with the latest date? Is there a way to do this without having to create a temp table with IDs and date?

User DateCreated
User 1 11/23/2008 <--- I need this record only
User 1 07/12/2008
User 1 03/20/2008


---
http://www.ssisdude.blogspot.com/

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-03 : 15:08:17
Select User, Max(datecreated)as Maxdate
from table
Group by User
Go to Top of Page

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2008-12-03 : 15:16:22
I need to get more sleep.


---
http://www.ssisdude.blogspot.com/
Go to Top of Page
   

- Advertisement -