romeiovasu
asked on
sql 2005 query
HI all,
i have table with
employeeid number
timein datetime
timout datetime
how can i calculate total punched hours. how can i calculate it timeout is null
the sample data i am giving.
empid storeid punchin punchout
2 1 2007-07-18 18:44:26.897 NULL
95 1 2007-08-22 17:20:04.373 NULL
2 5 2007-08-21 08:00:00.000 2007-08-21 10:00:00.000
2 5 2007-08-21 20:43:17.387 2007-08-22 11:08:40.343
59 7 2007-10-02 15:10:00.000 2007-10-02 18:56:44.973
62 7 2007-09-08 09:15:00.000 2007-09-08 19:30:00.000
62 7 2007-09-17 09:21:00.000 2007-09-17 17:00:00.000
i have table with
employeeid number
timein datetime
timout datetime
how can i calculate total punched hours. how can i calculate it timeout is null
the sample data i am giving.
empid storeid punchin punchout
2 1 2007-07-18 18:44:26.897 NULL
95 1 2007-08-22 17:20:04.373 NULL
2 5 2007-08-21 08:00:00.000 2007-08-21 10:00:00.000
2 5 2007-08-21 20:43:17.387 2007-08-22 11:08:40.343
59 7 2007-10-02 15:10:00.000 2007-10-02 18:56:44.973
62 7 2007-09-08 09:15:00.000 2007-09-08 19:30:00.000
62 7 2007-09-17 09:21:00.000 2007-09-17 17:00:00.000
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(Select empid, storeid, Case when punchout is null then 0 else
DateDiss(hours , punchin, punchout) end as hours from employee)A
group by empid, storeid