Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calculate Time Worked

Author  Topic 

aturner
Starting Member

29 Posts

Posted - 2004-06-03 : 17:56:22
I need to be able to enter FromDateWorked to ToDateWorked along with CurrentHoursWorked and be able to calculate the TotalHoursWorked by employee on two joining tables.

Does any one know how to do this using a SQL 2000 stored procedure? Thirdly, should I create two tables; one for employee information, and the secondly, to enter the dates and time worked based upon the employee id in both tables.

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-03 : 18:39:55
??? Are you trying to figure out:

SELECT
SUM(Hours)+@CurrentHoursWorked
FROM
HoursTable
WHERE
WorkDate >= @FromDateWorked
AND WorkDate <= @ToDateWorked

Why do you need to enter currenthoursworked??? Is it not already in the table?

You should definitely break out the hours worked from your core employee information table.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

aturner
Starting Member

29 Posts

Posted - 2004-06-03 : 18:50:12
Your right. I wasn't sure that I needed to have the CurrentHoursWorked included in the calculation. Should the employee id be included in the select statement you submitted?
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-03 : 19:01:11
Well, my query above would return the totals for everyone. You would need to put the employee_id in both the select and group by to have it work per employee, so yes.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

aturner
Starting Member

29 Posts

Posted - 2004-06-03 : 19:02:09
Thank you.
Go to Top of Page
   

- Advertisement -