mysql> select name,selecting,rejecting from((select name,selecting,rej
+ecting from ues order by name desc limit 5 )union all(select 'others
+' as name ,sum(selecting) as selecting ,sum(rejecting) as rejecting
+from (select selecting,rejecting from ues order by name desc limit 18
+446744073709551615 offset 5) go)) go;
+-------------+--------------+--------------+
| name | selecting | rejecting |
+-------------+--------------+--------------+
| normal | 131 | 4 |
| spectreRF | 46 | 40 |
| vcs | 0 | 0 |
| ncsim_short | 0 | 174 |
| ncsim_lp | 0 | 3 |
| others | 13633 | 659 |
+-------------+--------------+--------------+
But my expected output as follows:
the table rows should be arranged from maximum value to minimum value and sum of selecting and rejecting column should be accurate as per the expected output.The others row to added and printed for the remaining values which are not included in the limit and addition of remaining values should start from offset.
+-------------+--------------+--------------+
| name | selecting | rejecting |
+-------------+--------------+--------------+
| vcs | 0 | 0 |
| spectreRF | 46 | 40 |
| normal | 131 | 4 |
| ncsim_short | 0 | 174 |
| ncsim_lp | 0 | 3 |
| others | 13633 | 659 |
+-------------+--------------+--------------+
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.