Running SQL Server 2008, and I am definitely a new SQL user.
I have a table that has 4 columns:
EmpNum, User, Action, Updatetime
A user logs into, and out of a system, it is registered in the database. For example, if user1 logs into the system, then out 5 minutes later, a simple query (select * from update) would look like:
EmpNum User Action Updatetime
1 User1 I 2010-01-01 23:00:00:000
1 User1 O 2010-01-01 23:05:00:000
I’m trying to query the Empnum, User, Action, I(in time), O(out time), and the total time.
EDIT In your comments you asked for TimeWorked. Since you are using SQL Server 2008, you can use an Outer Apply to calculate the out-time for each in-time row. Then it is a simple matter of using DateDiff.