Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

group by on 2 columns from 2 tables

Rakesh119-OracleJun 7 2017 — edited Jun 8 2017

Hi,

I have table1

col1 Parent_party_name

col2 forecasted_amt_acd

col3, col4...

Table2

col1 Parent_name

col2 cancelled amount

col2, col3..

I want to write a query which picks up the following

1. abc on col1 from table1

2. sum(col2) from table1 for abc

3. search for abc in col1 of table2

4. if it is there then sum(col2) for abc from table2

I have tried this query

select a.PARENT_PARTY_NAME, sum(a.FORECAST_AMOUNT_TO_CANCEL_ACD) as "At-Risk",

       sum(b.PROD_VALUE_CAN_ACD) as "Cancelled"

       from RIMINI_AT_RISK_MAIN_V2 a,

            RIMINI_CANCELLATION b

            where a.PARENT_PARTY_NAME = b.PARENT_NAME

            group by a.PARENT_PARTY_NAME, b.PARENT_NAME

but doesn't give me the expected result.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2017
Added on Jun 7 2017
8 comments
2,453 views