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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: sql query on substract

RE: sql query on substract

From: <cosltemp-g.manoj_at_orbitech.co.in>
Date: Fri, 26 Jul 2002 03:18:19 -0800
Message-ID: <F001.004A3246.20020726031819@fatcity.com>


  data


s_month s_sum

  JAN         1000
  FEB         1200
  MAR         1250
  APR          2000

query



select b.s_month b_mth,s_sum - a.amt
from x_test b,
(

 select s_month,s_sum amt
 from x_test
) a
where (b.s_month = a.s_month and
      (b.s_month = 'JAN'))
            or   

  (b.s_month = to_char(add_months(to_date(a.s_month,'MON'),1),'MON'))   order by to_date(b.s_month,'MON')  

output


JAN 0
FEB 200
MAR 50
APR 750    -----Original Message-----

   From:       jonny99delmont [mailto:jonny99delmont_at_yahoo.co.uk]
   Sent:       Friday, July 26, 2002 3:13 PM
   To:         ORACLE-L
   Cc:         jonny99delmont

   Subject: sql query on substract    

    << File: sql query on substract.HTM >>    

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: cosltemp-g.manoj_at_orbitech.co.in

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Fri Jul 26 2002 - 06:18:19 CDT

Original text of this message

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