Link to home
Start Free TrialLog in
Avatar of romeiovasu
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
Avatar of srafi78
srafi78
Flag of United States of America image

Select empid, storeid, sum(hours) from
(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
ASKER CERTIFIED SOLUTION
Avatar of srafi78
srafi78
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of David Todd
David Todd
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial