If you where to store the start time and end time of each employee in
another table it would be very easy.
loop through the half hour intervals and count the number of records/employees whos start time is before or equal to the interval time and finish time is after the interval time.:D
As your table stands
You would have to loop through the interval times-- and "count" those who started at that time, then add the four hour starters who's starting interval is greater than the interval in question - 4 hours, then add the five hour starters who's starting interval is greater than the interval in question - 5 hours, etc
Basically, using a different query for each time interval and summing the starters
ie:
Select a distinct set of starting times
loop through the starting times
select a count of the empoyees who start at that starting time
select a count of the 4 hr PT's how have a starting time less than this time and greater than this time less four hours.
Add this count to previous
select a count of the 5 hr PT's how have a starting time less than this time and greater than this time less five hours.
Add this count to previous
and so on...
then do this for the next starting time
and so on
