+---------------+--------------+--------------+
| queue_name | jobs_pend | jobs_run |
+---------------+--------------+--------------+
| adice_long | 5 | 39 |
| adice_ncsim | 0 | 6 |
| adice_short | 254 | 192 |
| calibre | 0 | 0 |
| dsp_ncsim_gls | 0 | 2 |
+---------------+--------------+--------------+
####
+---------------+--------------+--------------+
| queue_name | jobs_pend | jobs_run |
+---------------+--------------+--------------+
| adice_short | 254 | 192 |
| adice_long | 5 | 39 |
| adice_ncsim | 0 | 6 |
| calibre | 0 | 0 |
| dsp_ncsim_gls | 0 | 2 |
| others | 212 | 218 |
+---------------+--------------+--------------+
####
use DBI;
use strict;
my $DBH = get_dbh();
my $sql = 'SELECT queue_name,jobs_pend,jobs_run
FROM queues order by jobs_run DESC';
my $sth = $DBH->prepare( $sql );
$sth->execute();
# input
my %table = ();
my $recno = 0;
while (my ($name,$pend,$run) = $sth->fetchrow_array){
my $key = ($recno++ < 5) ? $name : 'other' ;
$table{$key}{'pend'} += $pend;
$table{$key}{'run'} += $run;
}
# output
for my $key (sort keys %table){
my @col = ($key);# col[0]
$col[1] = $table{$key}{'pend'};
$col[2] = $table{$key}{'run'};
printf "| %-25s | %3d | %3d |\n",@col;
}