my $sth = $dbh->prepare('SELECT DISTINCT surveys, COUNT(*) FROM neverland GROUP BY surveys ORDER BY surveys DESC'); $sth->execute() or die $sth->errstr; while (my @result = $sth->fetchrow_array()) { my $percent = (@result[1] / $nothernumber)*100; printf qq(@result[0]@result[1]%.1f%%\n),$percent; }