
February 10th, 2008, 01:48 PM
|
|
Registered User
|
|
Join Date: Jan 2008
Posts: 8
Time spent in forums: 1 h 14 m 9 sec
Reputation Power: 0
|
|
|
Urgent -query help log in log out sum
I have two tables u_hist and persl_hist
each table has columns that I need, to get the information that I need. (basically one table has the event status (I only need the events ln and lo which are log out log in events and thier corresponding times. the other has the employee ids, I need to figure out how to loop through the tables for a certain employee during a certain date range, and calculate the hours worked by taking a log on time and subtracting it from a log off time then adding the results of each day. the problem is that there are not an equal amount of log off times to log on times.
my sql goes like this
SQL11 = SELECT U_hist.ts, U_hist.unit_status
FROM persl_hist, u_hist
WHERE U_hist.ts BETWEEN '20070701000000pd' AND '20070801000000pd'
AND U_hist.unit_status='Logon' Or U_hist.unit_status='logoff' AND U_hist.uid=persl_hist.uid
AND persl_hist.empid =30973
A lot I know but this gets the log off log on datetimestamp
for a particular employee,, but I cant seem to loop through it taking the first log on and the next log off to do the math to ge t the hours worked. I run into the problem where there are extra log on times or actually the employee would forget to log off. I need to skip those some how..PLEASE HELP
Reply With Quote
|