I need to modify the code below to add a breakdown of each months totals. Currently the data is only showing total tickets in one row. I want to be able to break the totals down into months so we can see what months are our busy months. I would like the layout to be shown similar to:

Month Name / Total Tickets / Total Filtered
Jan / 200 / 109
Feb / 216 / 134

Code:
        $qry = "select count(ticket_number)from tickets where open_time > '$start_epoch' and open_time < '$stop_epoch'";
	$sth = $dbh->prepare("$qry");
	$sth->execute();
	$count1 = $sth->fetchrow_array();
	$count1 = "(Couldn't obtain count)" if !defined($count1);
	$sth->finish();

        $qry = "select count(ticket_number)from tickets where open_time > '$start_epoch' and open_time < '$stop_epoch' and notes != 'automated Ticket' and notes != 'Customer Opened'";
	$sth = $dbh->prepare("$qry");
	$sth->execute();
	$count2 = $sth->fetchrow_array();
	$count2 = "(Couldn't obtain count)" if !defined($count2);
	$sth->finish();

	&reportHeader;
	print "<table border=0 width=25% cellspacing=1 cellpadding=2>";
	print qq{<tr><td>Total Tickets Opened:</td><td>Filtered Tickets Opened:</td>};
	$lastUpdate = localtime($ref->{'last_update'});
	print qq{<tr><td>$count1</td><td>$count2</td></tr>};
The date selection comes from (based on 2 input fields):
Code:
        $start = $input{'start_date'};($start_m,$start_d,$start_y) = split(/\//,$start);
	$stop = $input{'end_date'};($stop_m,$stop_d,$stop_y) = split(/\//,$stop);

	$stop_m -= 1;
	$start_m -= 1;

	$start_epoch = timelocal(0,0,0,$start_d,$start_m,$start_y);
	$stop_epoch = timelocal(59,59,23,$stop_d,$stop_m,$stop_y);

	$startgood = localtime($start_epoch);
	$stopgood = localtime($stop_epoch);
I know I need to have a loop in here somewhere. I am just not sure what the easiest way to do this would be.