Solved

Help with SQL

Posted on 2013-01-02
1
160 Views
Last Modified: 2013-01-02
Hi.
I have a table of login data. Need to find the most recent login by user - return single record for each user - need group by user and most recent login datetime
The data looks this

USER                    DATETIME LOGIN
JOHN                    1/2/2013  1:00
GAYLE                   1/2/2012  9:00
JOHN                    12/31/2012  12:00
GAYLE                   12/31/2012 10:00
BOB                      1/2/2012  12:00


SHOULD RETURN

GAYLE              1/2/2012  9:00
JOHN               1/2/2013  1:00
BOB                1/2/2012  12:00


thx
0
Comment
Question by:JElster
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 320 total points
ID: 38736642
select [user], max(datetime_login)
from login_history
group by [user]
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question