actually i think it is working now...
here is my code that i'm using now:
$result = mysql_query("select g.help_desk_group_id,
sum(case when 0 - TO_DAYS(r.start_date) <= 2 then 1 else 0 end) '02',
sum(case when (0 - TO_DAYS(r.start_date) > 2) AND (0 - TO_DAYS(r.start_date) < 6) then 1 else 0 end) '35',
sum(case when (0 - TO_DAYS(r.start_date) > 5) AND (0 - TO_DAYS(r.start_date) < 10) then 1 else 0 end) '610',
sum(case when 0 - TO_DAYS(r.start_date) >= 10 then 1 else 0 end) '10plus'
FROM help_desk_group g left join help_desk_thread t on g.help_desk_group_id = t.help_desk_group_id left join help_desk_request r on t.request_id = r.request_id
WHERE r.start_date IS NOT NULL AND r.close_date IS NULL
GROUP BY g.help_desk_group_id") or die(mysql_error());
while(list($help_desk_group_id, $v1, $v2, $v3, $v4) = mysql_fetch_row($result)) {
$group_array[$help_desk_group_id][1] = $v1;
$group_array[$help_desk_group_id][2] = $v2;
$group_array[$help_desk_group_id][3] = $v3;
$group_array[$help_desk_group_id][4] = $v4;
}
this should get all the open requests, and seems to sum up correctly.
my problem before is that i was looking at the wrong table... 1 group had 12 threads open, but they had 8 other threads closed where the request was still open (multiple groups were working on the same request)
this is all for a very cool help desk system i made for our companies intranet... the IT director just wanted a report to see how each department was handling requests, and how they were being rated. there is a feedback system tied into it, and i used a similar query to get stats on how each department did on average, and then broke it down by rating category (timeliness, results, attitude, etc...)