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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query rephrase

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2011-05-24 : 14:40:52
i have a table structure like this:




CREATE TABLE [dbo].[STG_UserEvent](

[userEventId] [uniqueidentifier] NULL,

[userId] [uniqueidentifier] NULL,

[eventTime] [datetime] NULL,

[eventType] [nvarchar](100) NULL

) ON [PRIMARY]


select userid,eventtime,eventtype

from STG_UserEvent as a

where eventTime > (Select Max(eventtime) from STG_UserEvent b

where eventType = 'Logout'

and a.userid=b.userid

)


eventype will contain the 'login' or 'logout'
eventtime will contain the time of login/logout

my query should be insuch a way that,it should show only display the pending item,which means if user is logged in and forgot to logout for a
particular day,then that list alone needs to be displayed..

can you please correct the query..

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-24 : 15:18:28
How exactly do you know that a user logged in and forgot to log out? Also, I will assume that you can't change the data type of the uniqueidentifier fields.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -