Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by chacham (Prior)
on Apr 04, 2017 at 19:36 UTC ( #1187041=note: print w/replies, xml ) Need Help??


in reply to Re: 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?

This isn't a ROLLUP, because you don't want totals. Instead, you could use the UNION ALL, but use a CTE so the subquery is only applied once. That is, use a WITH to SELECT all the rows in the TABLE, but add ROW_NUMBER() OVER (ORDER BY queue_name). To avoid the UNION ALL (which in this case would have little to no point, as the CTE already makes a centralized query) you could wrap the ROW_NUMBER() in a CASE to go no higher than 6.Then a single aggregate query with a GROUP BY on the row number.

  • Comment on Re^2: How to add columns with new row name using perl from mysql query?

Log In?
Username:
Password:

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

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












    Results (256 votes). Check out past polls.

    Notices?