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 -> Re: SQL to compute sums (similar to SQL*plus break on <column> compute sum of <other_col> on <column>)

Re: SQL to compute sums (similar to SQL*plus break on <column> compute sum of <other_col> on <column>)

From: Nicholas Carey <ncarey_at_speakeasy.org>
Date: Fri, 30 Nov 2001 19:22:13 -0000
Message-ID: <Xns916973A964613ncareyspeakeasyorg@207.126.101.92>


On 29 Nov 2001, andreyNSPAM_at_bookexchange.net (NetComrade) spake and said:

> I know there is some 'new' SQL that can do this, but can't
> think of a way to look for it. Although not sure which
> version it was introduced in 8i or 9i.

Not sure what your look for, but it might be this:

  select yyyy  ,
         mmm   ,
         dd    ,
         sum(amount_sold) amount_sold

  from foo
  group by yyyy,mmm,dd
  order by yyyy,mmm,dd
  compute sum(sum(amount_sold)) by yyyy,mmm
  compute sum(sum(amount_sold)) by yyyy
  compute sum(sum(amount_sold))

Not exactly 'new' SQL, but it will give you subtotals and totals at every sequence break.

-- 
Received on Fri Nov 30 2001 - 13:22:13 CST

Original text of this message

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