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!

sum of segment values in oracle

User_AE8FXMay 3 2019 — edited May 3 2019

Hi All,

I have data like this..

select 11111 SOURCE_ID , 500 AMOUNT_CR ,681000 SEGMENT5 from dual

union all

select 11111 SOURCE_ID , 17.25 AMOUNT_CR ,102005 SEGMENT5 from dual

union all

select 22222 SOURCE_ID , 300 AMOUNT_CR ,681000 SEGMENT5 from dual

union all

select 22222 SOURCE_ID , 500 AMOUNT_CR ,681000 SEGMENT5 from dual

union all

select 22222 SOURCE_ID , 27.7 AMOUNT_CR ,102005 SEGMENT5 from dual

Current output( I will not take segment5 column to select statement)

    

SOURCE_IDAMOUNT_CRSEGMENT5
11111500681000
1111117.25102005
22222300681000
22222500681000
2222227.7102005

I need to sum (AMOUNT_CR column) if i have more than 2 rows other than 102005 SEGMENT5 of each SOURCE_ID.

Expected output

  

SOURCE_IDAMOUNT_CR
11111500
1111117.25
22222800
2222227.7

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

Comments
Post Details
Added on May 3 2019
3 comments
245 views