in reply to loop though query results twice
Why not push the work of combining stuff into the DB?
my $sth = $dbh_bob->prepare(<<SQL); SELECT name, birthdate_date, gender, company FROM namespace.directory order by company SQL $sth->execute(); my $results = $sth->fetchall_arrayref(Slice=>{}); my $cur_company; my $line; for my $row (@$results) { if ($cur_company ne $row->{company}) { $cur_company = $row->{company}; $worksheet = $excel->addworksheet($cur_company); $line = 0; }; $worksheet->write_row($line++,0,$row); };
|
|---|