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.
| Author |
Topic |
|
Trafmore
Starting Member
6 Posts |
Posted - 2007-05-30 : 12:13:22
|
| SQL SUM FunctionHi every one, I am writing a web application that keeps track of the hours that an employee work. The employee has to log on to the site and there record the times that he works each day and that includes any over time.I am trying to get the total time worked for a specific period for any employee and I’ m having problems coming up with the way to achieve this. Can any one help? This is where I am so far with my TSQLSELECT SUM(Hours_On_Duty) + SUM(Paid_Over_Time) + SUM(Unpaid_Over_Time) AS Hours, EmpIDFROM dbo.TimeInfoWHERE (Date = Date)GROUP BY EmpIDPlease help.Trafmore |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-30 : 12:50:30
|
I think you need to change your where clause to something like this:where DateCol between @startDate and @endDate www.elsasoft.org |
 |
|
|
Trafmore
Starting Member
6 Posts |
Posted - 2007-05-30 : 13:14:13
|
| I did what you said but it did not give what I was looking for. It gave me the individual amount of hours for each date. But what I want is the sum of all the hours. |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-30 : 13:28:00
|
perhaps you should post your table DDL, sample data in the form of insert statements, and your expected result. www.elsasoft.org |
 |
|
|
|
|
|