D
Dale Fye
Thanks in advance for your help
I'm working with a database pulled from a commercial application.
This application records a variety of events associated (enter a room,
exit room, logon, logoff) with users, as well as some system events
(system reboot). What I'm trying to do is determine how many users
are in a room at a specific point in time, and in another instance,
how many distinct users have been in a room at any point during a
specific time period.
My Events table looks something like:
UserID, varchar(20)
EventDesc, varchar(20): ('Enter room', 'Exit room', 'Logoff', 'Logon',
'Reboot')
RoomID, int
EventTime, Date
My problem is that the version of the program whose data I am working
with did not elegantly close things out. It allowed users to logoff
without first generating events to Exit them from whatever room(s)
they were in, and whenever the system crashed and rebooted, it does
not generate transactions which exit the users from a room.
What I'd like the results of my query to look like is:
RoomID, UserID, EnteredRoom_dt, ExitedRoom_dt
Where the ExitedRoom_dt value is determined by the smaller of the
following three values:
1. first time the user exits the room after entering it
2. first time the user logged out after entering the room
3. first system reboot after the user entered the room
I've been able to implement this using procedural code in my ASP, but
know there has to be a quicker way to do it using a query.
I'm working with a database pulled from a commercial application.
This application records a variety of events associated (enter a room,
exit room, logon, logoff) with users, as well as some system events
(system reboot). What I'm trying to do is determine how many users
are in a room at a specific point in time, and in another instance,
how many distinct users have been in a room at any point during a
specific time period.
My Events table looks something like:
UserID, varchar(20)
EventDesc, varchar(20): ('Enter room', 'Exit room', 'Logoff', 'Logon',
'Reboot')
RoomID, int
EventTime, Date
My problem is that the version of the program whose data I am working
with did not elegantly close things out. It allowed users to logoff
without first generating events to Exit them from whatever room(s)
they were in, and whenever the system crashed and rebooted, it does
not generate transactions which exit the users from a room.
What I'd like the results of my query to look like is:
RoomID, UserID, EnteredRoom_dt, ExitedRoom_dt
Where the ExitedRoom_dt value is determined by the smaller of the
following three values:
1. first time the user exits the room after entering it
2. first time the user logged out after entering the room
3. first system reboot after the user entered the room
I've been able to implement this using procedural code in my ASP, but
know there has to be a quicker way to do it using a query.