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)
 select query to get cumulative hours each employee

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-02-01 : 15:22:38
i want to get the cumulative hours for each username(employee) for dates between 01/01/2006 and 12/31/2006

can you please help:
*******************************************************************
select username, hours from timesheet where work_date > 01/01/2006 and work_date < 12/31/2006
*******************************************************************

Thank you very much for the information.

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2008-02-01 : 15:25:59
Sounds like you just need to sum the hours and group by the employee / username.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-02-01 : 15:28:57
Yes...

quote:
Originally posted by Van

Sounds like you just need to sum the hours and group by the employee / username.

Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2008-02-01 : 15:42:36
Do you not know how to do a sum or a group by?

select field1, sum(field2) from table1
group by field1 (you can put a where clause in between the select and the group by)
Go to Top of Page
   

- Advertisement -