Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> R: Programming in SQL?
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