Chunking Returned MySQL Dataset Into Multiple Arrays
I'm working to compute the median hours to resolution for tech support workers in my organization. I have pretty good idea of what needs to happen to compute the median, I'm just not sure how to get there.
I currently have a mysql dataset being returned with values similar to the data below.
I'm guessing I need to break this data into multiple arrays, so I would have an array of Astudillo's data, and array of Blakeman's data, etc. Count the number of elements in each array. Then, if the number of elements in that array is odd, grab the middle element. If the number of elements is even, get the sum of the middle two elements / 2.
Any help is appreciated. I'm really having trouble getting started.
Are you trying to compute the median for each person or a median for everybody? If for each person why not just query for a list of people and use that result to query the other data you need for computations and then do the computation for each.
1. Get a list of all the tech support personnel
2. Use that list in a foreach loop to query each person for the list of hours they worked
3. Compute the median
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
It would be easier if you didn't try to rework the data after getting it from the database. You didn't provide any information on your database structure but if you did this correctly you should be able to do something as simple as this:
In place of the hardcoded array you would loop through the resultset from the query in much the same way.