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 2005 Forums
 Transact-SQL (2005)
 Employee Hours Worked Table

Author  Topic 

jj32smith
Starting Member

7 Posts

Posted - 2007-06-27 : 20:13:29
I have a table that has
Employee Number,
Beginning Work DateTime
Beginning LunchDateTime
Ending LunchDateTime
Ending Work Date Time

I would like to create a select statement for a giving date range that brings back the total hrs worked over that data range.

Can someone help me with this query?

Thanks

Koji Matsumura
Posting Yak Master

141 Posts

Posted - 2007-06-27 : 20:41:57
What have you tried so far?
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-27 : 21:18:19
Post some sample code and expected result so what we understand is same as what you want.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

jj32smith
Starting Member

7 Posts

Posted - 2007-06-27 : 22:54:27
Here is what I have so far but, this brings back every entry for the specific employee

SELECT
EMPNO, BEGWRK, BEGLUN, ENDLUN, ENDWRK,
((ENDWRK - BEGWRK)- (ENDLUN-BEGLUN))
FROM EMPHOURS
WHERE EMPHOUR.EMPNO='123' or EMPHOUR.EMPO = '125')

I would like the query to only bring back one record for each employee and the total hrs wrked for this employee.


Thanks for your help.
Go to Top of Page

Koji Matsumura
Posting Yak Master

141 Posts

Posted - 2007-06-27 : 23:44:17
quote:
Originally posted by jj32smith

I have a table that has
Employee Number,
Beginning Work DateTime
Beginning LunchDateTime
Ending LunchDateTime
Ending Work Date Time

I would like to create a select statement for a giving date range that brings back the total hrs worked over that data range.

Can someone help me with this query?

Thanks




What do you mean by "over that data range"?
Go to Top of Page
   

- Advertisement -