my $sth = $dbh->prepare("SELECT DISTINCT state, COUNT(*) FROM contacts WHERE state != '' AND identifier BETWEEN '2003-01-01' AND '2003-02-01' GROUP BY state ORDER BY 2 DESC"); $sth->execute() or die $sth->errstr; my $rows = 0; while (my @result = $sth->fetchrow_array()) { last if $rows++ >= 10; print qq(

$result[0]

 
$result[1]
0
\n); } $sth->finish();