We are excited to announce that the ASP.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

## 2 replies

Last post Oct 22, 2018 01:20 PM by paindaasp

• binustrat

Member

35 Points

156 Posts

### Calculate total man hours spend on each task

Hi all

I had two tables, One is employees attendance table and another one is employees task tables

Attendance table containing columns like EmpId, workeddate, ActualHours worked in a day etc

From these how i get total hrs spend by all employees in each task

Consider if one emp work on one task today probably he will work on another task tomorrow

Below I giving my table structure

<div>Attendance table</div> <div> </div> <div>EmpId  workedDate ,   ActualHrsWorked</div> <div> </div> <div> 1001    09-10-2108       10</div> <div> 1001    10-10-2018       09</div> <div>1001     11-10-2018       8</div> <div>1002     09 -10-2018      11</div> <div>1002     10-10-2018       06</div> <div>1003     11 -10-2108      12</div> <div> </div> <div> </div> <div>Task Table </div> <div> </div> <div>EmpId workedDate      TaskId</div> <div> </div> <div>1001    09-10-2108      101</div> <div>1001    10-10-2018      102</div> <div>1001    11-10-2018      101</div> <div>1002    09 -10-2018     101</div> <div>1002    10-10-2018      101</div> <div>1003    11 -10-2108     102</div> <div></div> <div></div> <div></div> <div>Expecting answer</div> <div></div> <div>taskId ActualHrsWorked
101 35
102 21
</div>
• eralper

Contributor

6101 Points

1449 Posts

### Re: Calculate total man hours spend on each task

Please try following SQL Select with SUM() aggregation function and Group By clause

```select
sum(a.ActualHrsWorked) as ActualHrsWorked
inner join employees_attendance as a
on t.Empid = a.Empid
and t.Workeddate = a.Workeddate

``` ```

• paindaasp

Star

11749 Points

2997 Posts

### Re: Calculate total man hours spend on each task

```With tblTaskHours(taskID, workedDate, taskHours)