Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select max(date) query 1

Status
Not open for further replies.
Dec 13, 2002
109
GB
I have a table with data:

username datelog
-------- -------
tom 01/01/2011 10:02:04
simon 06/04/2011 09:06:05
steve 05/05/2010 11:21:56
tom 07/11/2009 12:34:56
steve 09/11/2011 11:34:00
simon 01/11/2010 09:43:45


I am trying to select the last (or most recent) datelog for each username so I should see:

tom 07/11/2009 12:34:56
simon 01/11/2010 09:43:45
steve 09/11/2011 11:34:00

Im going nuts as my queries dont seem to select just the one row for each username. The datelog field is of type date
 
Code:
select username,max(datelog)
from table_1
group by username

[code/]

[bandito] [blue]DBomrrsm[/blue] [bandito]

[blue]Software code, like laws and sausages, should never be examined in production[/blue][black] - [/black][purple]Edward Tenner[/purple]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top