$poll = $DB_site->query_first("SELECT COUNT(poll.pollid) AS count, SUM(voters) AS voters FROM poll LEFT JOIN thread ON (poll.pollid=thread.pollid) WHERE thread.forumid=$forumid"); $averagevotes=$poll['voters']/$poll['count'];