February 3, 2006 at 4:22 am
I'm trying to return a value in a select statement which is marked as Online or Offline depending on the value in a date column. The date column marks when the user was last online.
A Sample of the SQL i've been trying to use is:
SELECT UserEmail, UserDisplayName, UserLastOnline = CASE UserLastOnline
WHEN DATEADD(mi, -10, GETDATE()) < LastOnline THEN 'Offline'
ELSE 'Online'
FROM tblContacts INNER JOIN tblUsers ON tblUsers.UserID = tblContacts.ListContactID
WHERE tblContacts.ListOwnerID = 100019
TIA,
Matt Brooke
February 3, 2006 at 5:01 am
You didn't write what the problem was But I guess your query fails. Try this instead:
SELECT UserEmail, UserDisplayName, CASE
WHEN DATEADD(mi, -10, GETDATE()) < LastOnline THEN 'Offline'
ELSE 'Online' END as UserLastOnline
FROM tblContacts INNER JOIN tblUsers ON tblUsers.UserID = tblContacts.ListContactID
WHERE tblContacts.ListOwnerID = 100019
If this doesn't work, please supply table definitions, error message and a description of what you are trying to do.
February 3, 2006 at 5:23 am
Many thanks there,
It was a syntax error I was getting and the solution provided fixed it!
Thanks again,
Matt
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply