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: how do I rewrite this query optimized

Re: how do I rewrite this query optimized

From: LKBrwn_DBA <member30625_at_dbforums.com>
Date: Tue, 22 Jul 2003 14:50:52 +0000
Message-ID: <3138509.1058885452@dbforums.com>

OK, try this:

update re
set paid =
(select re.paid

      + decode(p.rtype,'xx', (-1 * pt.amt)
                      ,'yy', (-1 * pt.amt),pt.amt)
   from p, pt
  where p.pk1col1  = re.fk1col1
    and p.pk1col2  = re.fk1col2
    and pt.fk1col1 = re.pk1col1
    and pt.fk1col2 = re.pk1col2)

where exists (
 select 1
   from p, pt
  where p.pk1col1  = re.fk1col1
    and p.pk1col2  = re.fk1col2
    and pt.fk1col1 = re.pk1col1
    and pt.fk1col2 = re.pk1col2);

--
Posted via http://dbforums.com
Received on Tue Jul 22 2003 - 09:50:52 CDT

Original text of this message

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