my $Select_max_score = "SELECT MAX(M.Score) FROM Regions M "; my $sth_max_score = $dbh->prepare($Select_max_score) or die "Couldn't prepare query: ".$dbh->errstr; $sth_max_score->execute() or die "Couldn't execute query: ".$sth_max_score->errstr; my @max_score; while (@max_score = $sth_max_score->fetchrow_array) { }