my $sth = $dbh->prepare('SELECT COUNT(*) FROM owner WHERE rent_car = "Y"'); $sth->execute() or die $sth->errstr; my $rent_car = $sth->fetchrow_array(); my $percent = ($rent_car / $result)*100; printf qq(Yes$rent_car%.2f%%\n),$percent; my $sth = $dbh->prepare('SELECT COUNT(*) FROM owner WHERE rent_car = "N"'); $sth->execute() or die $sth->errstr; my $rent_car2 = $sth->fetchrow_array(); my $percent2 = ($rent_car2 / $result)*100; printf qq(No$rent_car2%.2f%%\n),$percent2; my $rent_carno = $rent_car + $rent_car2; my $rent_carnor = $result - $rent_carno; my $percent3 = ($rent_carnor / $result)*100; printf qq(No Response$rent_carnor%.2f%%\n),$percent3;