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.
| Author |
Topic |
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2005-05-19 : 13:18:35
|
| Need help. I am trying write a query that will return the latest date value. For example i have the following table:User LoginDateTom 2005-03-23 14:28:37.000Tom 2005-03-24 14:42:11.000Tom 2005-03-25 14:42:11.000I want to return the latest date.Tom 2005-03-25 14:42:11.000Thanks in advance. |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2005-05-19 : 13:34:29
|
| SELECT MAX(LoginDate) As MaxLoginDate FROM MyTableORSELECT TOP 1 LoginDate FROM MyTable ORDER BY LoginDate DESC |
 |
|
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2005-05-19 : 13:42:26
|
| Sweet that worked great! |
 |
|
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2005-05-19 : 13:54:57
|
| Ok. Now i have another problem. I have the following table:User LoginDateTom 2005-03-20 14:28:37.000Tom 2005-03-23 14:28:37.000Tom 2005-03-24 14:28:37.000Jim 2005-03-21 14:28:37.000Jim 2005-03-23 14:28:37.000Adam 2005-03-22 14:28:37.000Adam 2005-03-24 14:28:37.000I need to retrieve the last login date for each user (I.E.Result:Tom 2005-03-24 14:28:37.000Jim 2005-03-23 14:28:37.000Adam 2005-03-24 14:28:37.000Please help! |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-05-19 : 13:59:51
|
SELECT User, MAX(LoginDate) As MaxLoginDate FROM MyTableGROUP BY UserBeauty is in the eyes of the beerholder |
 |
|
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2005-05-19 : 14:06:29
|
| Works great!!! THX AGAIN! |
 |
|
|
|
|
|