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
 Transact-SQL (2000)
 multiple entries with different dates needs organizing

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-17 : 07:54:55
david writes "i have a table named guest. everytime a guest logs in, my database creates an entry with their name and another column with the date they logged in. there are multiple entries with the same name. i would like to just see a single record for each name showing the most recent date that they logged in. any ideas? i'm using SQL2000 with windows 2003

example

david 10/15/2006
david 10/13/2006
david 10/10/2006
mark 10/14/2006
mark 10/10/2006

i need the query results to be the most recent date

david 10/15/2006
mark 10/14/2006"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-17 : 08:31:14
[code]
select *
from guest g
where datecol = (select max(datecol) from quest x where x.name = g.name)
[/code]


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-17 : 10:30:58
or

Select name, max(date) as date from table
Group by name

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -