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 -> R: Programming in SQL?

R: Programming in SQL?

From: Riccardo Ferrari <riccardo.ferrari_at_informatica2.it>
Date: Wed, 27 Oct 1999 11:29:22 +0200
Message-ID: <7v6gm9$cnv$1@nslave1.tin.it>


Here is the query
SELECT
      Table_A.<dollar_field_in_A> + SUM_IN_B FROM

     Table_A,
     (
     SELECT
           <join_field_in_B>  JOIN_B,
           sum(<dollar_field_in _b>)  SUM_IN_B
      FROM
           Table_B
      GROUP BY
           <join_field_in_b>)
      )
WHERE
     Table_A.<join_field_in_A> = JOIN_B;

Is the query clear?

Bye,
Riccardo

> > I have two tables: Table A and Table B. There is a one to many
> relationship from Table A to Table B. What I want to do, for the dollar
> amount fields, is for matching records in the tables, I want sum the
> records in Table B first, then add it to the field in Table A.
>
> So,
>
> Table A has one record with a dollar amount of $100.
> Table B has three records with dollar amounts $100, $100 and -$100.
>
> I want to sum those records in Table B BEFORE adding them to Table A.
Received on Wed Oct 27 1999 - 04:29:22 CDT

Original text of this message

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