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',sum(jobs_pending) int as jobs_pending,sum(jobs_running) as jobs_running from (select jobs_pending,jobs_running from queues order by queue_name limit 0 offset 5 ) foo)) foo;