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 awhere 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/logoutmy 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..