By go re
Here i had added my query part from my per1 program.
my $stmt="select queue_name,jobs_pending,jobs_running from((select queue_name,jobs_pending,jobs_running from queues order by queue_name limit 5 )union all(select 'others' as queue_name ,sum(jobs_pending) as jobs_pending ,sum(jobs_running) as jobs_running from (select jobs_pending,jobs_running from queues order by queue_name limit 18446744073709551615 offset 5 ) foo)) foo;";
In the above query the queue name filters the rows by limit 5.Then it sums the jobs_pending and job_running column from the offset 5 that it adds after the 5th row.
Now my query is i want to arrange the rows descendingly for both jobs_pending and jobs_running simultaneously and addition should be performed after descending the rows.The remaining rows after 5th row should be added and stored in the others row .How can i do it?
Source: Stack Overflow