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

Link to comment
Share on other sites

I meant that some jobs may contain 5 rows of data, and some jobs may contain 3 rows.  It all depends on what day had what category of work done.

 

See my example up top:

 

Job 1 has 4 rows to sum

job 2 has 2 rows to sum.

 

Scott

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.