ok im counting up the total tickets per dept for support, easy enough, but i want to count how many in each category. i had a script just looping for each dept, select each cat, count ticket ids well that works but it really bogs down bag and takes too long to get the tickets from say aug 1 to today so jsut one query getting all tickets, dept, cat foreach ticket from those days takes just .5 sec much better but now i need to count how much of each so i put all teh depts in an arry $depts[$deprow['dept_id']] = $deprow['name']; and all cats in an arry $categories[$catrow['cat_id']] = $catrow['name']; so i can match a name to the cat id when we psit the data out then i build an array of the tickets $ticket['dept'] = $row['dept_id']; $ticket['cat'] = $row['cat_id']; $tickets[] = $ticket; now, how do i count all the tickets for just one dept, one cat , a sum of all that match that for each disticnt type