$DB->query("create temporary table {$DB->_}membervote_recent ( unique key stage (member) ) select member, max(time) as time from {$DB->_}membervote where stage=$this->stage and division=$this->division group by member;"); $records = $DB->query( "select x.chara as chara, sum(x.weight) as score from {$DB->_}membervote as x, {$DB->_}membervote_recent as y where x.stage=$this->stage and x.division=$this->division and x.member=y.member and x.time=y.time group by x.chara;");