Jump to content

sum of columns from multiple varying rows


sdbeach

Recommended Posts

I am trying to sort by date.

 

The date returns 'job numbers' that contain information about how many hours was worked on each job.

 

I would like to be able to sum all of the hours worked by the job number. The job number contains varying amounts of columns depending on what job is picked.

 

The date is picked from a date picker, then I would like the results to appear like below.

 

So:

 

| job |    date      | a_hrs    | b_hrs      |  c_hrs    |

--------------------------------------------------------------- 

|job1|    8\8\12    |    3 hr    |    6hrs    |      2hrs  |

|job1|    8\8\12    |    2 hr    |    3hrs    |      4hrs  |

|job1|    8\8\12    |    3 hr    |    4hrs    |      5hrs  |

|job2|    8\8\12    |    3 hr    |    6hrs    |      2hrs  |

|job1|    8\8\12    |    3 hr    |    6hrs    |      2hrs  |

|job2|    8\8\12    |    3 hr    |    6hrs    |      2hrs  |

 

Result I desire:

 

|    job1    |    8\8\12    |    11 hr    |    19hrs      |      13hrs    |

|    job2    |    8\8\12    |    6 hr      |    12hrs      |        4hrs    |

 

 

Thanks in advance for any help.

Scott

I assume you mean columns? Because it doesn't matter how many rows it is, SUM adds them. If you mean columns, your example does not show different numbers of columns. Further more, given the test data, what I posted creates your desired output.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.