Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How to add columns with new row name using perl from mysql query?

by choroba (Archbishop)
on Apr 03, 2017 at 07:57 UTC ( #1186790=note: print w/replies, xml ) Need Help??


in reply to How to add columns with new row name using perl from mysql query?

Just change the query to
SELECT * FROM ( SELECT queue_name, jobs_pend, jobs_run FROM queues ORDER BY queue_name LIMIT 5 ) UNION ALL SELECT 'others', SUM(jobs_pend), SUM(jobs_run) FROM ( SELECT jobs_pend, jobs_run FROM queues ORDER BY queue_name LIMIT 18446744073709551615 OFFSET 5 )

Note: Tested only in SQLite, but it seems the LIMIT syntax is the same as in MySQL according to a cursory glance at the documentation. (Well, in fact, the large number has to be lower in SQLite, but MySQL documentation shows this constant).

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: How to add columns with new row name using perl from mysql query?
by perlanswers (Initiate) on Apr 03, 2017 at 08:46 UTC
    Hi,
    why you had included limit range so long?
      Because you want to sum over all the remaining rows, but you don't know their number. So I used the maximal possible number of rows, as shown in the documentation.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        Offset without limit ?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1186790]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2020-10-27 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (256 votes). Check out past polls.

    Notices?