Solved

Help with SQL

Posted on 2013-01-02
1
158 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

867 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now