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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

max(date) question 1

Status
Not open for further replies.

oakpark5

Programmer
Sep 2, 2004
81
US
I'm not sure how to do this exactly but this what i have so far:
Select event,max(date) from tctest where event=@newEvent and userid=@contentUserid

What i am trying to do, is retrieve the event from the most recent date for a certain user....if someone could just steer me int he right direction that would be nice, thanks in advance!

Software Engineer
Team Lead
damn bill gates, he has everything
 
Of course it might be better if SQLSister had started her sentence with You instead of ou.

Questions about posting. See faq183-874
 
You dont want to see these tables, they are a nightmare, another probelm i have is that the statement i am using now from SQLBill:

SELECT Event, UserID
FROM tctest
WHERE [Time] = (SELECT MAX([Time]) FROM tctest
WHERE [Date] = (SELECT MAX([Date]) FROM tctest))

This works for the test table I created, which is identical to the live table, except the times(which are characters) are in 24 hour format on the live table and 12 hour format on my test table. The statement works perfectly with my test table and the 12 hour format but not the 24 hour format. It come back with some very strange returns when run in query analyzer. Any ideas? Is the 24 hour format throwing it off?

Software Engineer
Team Lead
damn bill gates, he has everything
 
Anything is possible. We need to see real live examples of your data before we can even begin to guess at the answers to your questions.

-------------------------------------
It is better to have honor than a good reputation.
(Reputation is what other people think about you. Honor is what you know about yourself.)
 
Run this in the live system:

SELECT TOP 5 Event, UserID, [Date}, [Time]
FROM tablename

Then let us know the results. That will give us an idea of how the data looks.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top