[thelist] Last Login Time SQL

Tim Gaunt info at thesitedoctor.co.uk
Tue Jan 9 14:02:39 CST 2007

Hi Noah,

How about:

	users u LEFT JOIN user_log l
		ON u.user_id = l.user_id
	DATEDIFF(dd, MAX(l.login_time), GETDATE()) >= 90



-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Noah St. Amand
Sent: 09 January 2007 19:46
To: thelist at lists.evolt.org
Subject: [thelist] Last Login Time SQL


I'm trying to come up with an SQL statement that will return all of the 
users who haven't logged in to a system in 90 days or more. I can get 
the information I need with a nested query, but given that there are a 
lot of records, it's pretty slow and inefficient. There must be a good 
way to do it, but I'm not fluent enough in SQL to figure it out.

The details: I have two tables, one of which, "users", stores typical 
user data (user_id, user_name, password, email) and the other, 
"user_log" just records logins (user_id, login_time). I need to get a 
list of all the user_names of people whose most recent login_time is 90 
days or more before right now.

This is classic ASP querying Access, but if anyone has any ideas in 
reasonably generic SQL, I can translate as necessary.


* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 

More information about the thelist mailing list