Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Oracle Query Math

Oracle Query Math

From: <trpost_at_gmail.com>
Date: Thu, 29 Nov 2007 16:30:44 -0800 (PST)
Message-ID: <b1675b5e-29d4-49d6-b54e-53cc63ba3034@a35g2000prf.googlegroups.com>


I have a query:

SELECT GROUP_NAME, PERCENT FROM GROUPSUMMARY WHERE REPORT_DATE= TO_DATE( '2007-10-01','YYYY-MM-DD') ORDER BY PERCENT DESC; I get results like this:

Group1     40
Group2     20
Group3     15
Group4     10
Group5     5
Group6     4
Group7     3
Group8     2
Group9     1

What I want is a query that returns the top 5 rows and then a sixth row with a calculation that is the sum of any result rows past row 5, which could be variable.

So I want the results to show this:

Group1     40
Group2     20
Group3     15
Group4     10
Group5     5
Other       10

Where "Other" is 100-(sum of rows 1-5).

Is this possible with a query? This is an Oracle 10G database, not sure about the patch level. Thanks for your help! Received on Thu Nov 29 2007 - 18:30:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US