in reply to Re^5: How to add columns with new row name using perl from mysql query?
in thread How to add columns with new row name using perl from mysql query?
Tested on MySQL
And added a missing comma, FROM, and table alias. (Oops!) Thank you. Why did you remove the case statement from the GROUP BY? That's the part that does the magical split. :) (Even if i did write it incorrectly.) If mysql won't support it there, it'd need to be added into the subquery, which begins to make it more confusing...
SELECT CASE WHEN @rownum <= @row_limit THEN queue_name ELSE 'others' END +queue_name, SUM(jobs_pend) jobs_pend, SUM(jobs_run) jobs_run FROM ( SELECT CASE WHEN @rownum <= @row_limit THEN @rownum ELSE @row_limit + + 1 END box, queue_name, jobs_pend, jobs_run FROM ( SELECT @row_num := @row_num + 1, queue_name, jobs_pend, jobs_run FROM queues, (SELECT @row_num := 0, @row_limit := 5) r ORDER BY queue_name ) q ) p GROUP BY box;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: How to add columns with new row name using perl from mysql query?
by poj (Abbot) on Apr 04, 2017 at 05:47 UTC | |
by chacham (Prior) on Apr 04, 2017 at 19:44 UTC | |
by poj (Abbot) on Apr 04, 2017 at 20:00 UTC |