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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to sum on condition

687347Mar 28 2009 — edited Mar 29 2009
Hello,
I have the following data:
INSTRUMENT_TYPE INSTRUMENT_CODE DESCRIPTION TRADE_DATE  QUANTITY OPEN_CONTRACTS TRADE_AMOUNT TRANSACTION_ID 
fceu            USDEUR QSA2     USD/EUR     10.11.2008   1700000        1700000  -1323575.21          1819 
fceu            USDEUR QSA2     USD/EUR     25.11.2008  13300000       15000000 -10233130.72          1882 
fceu            USDEUR QSA2     USD/EUR     28.11.2008 -15000000              0  11598237.07          1908 
fceu            USDEUR QSA2     USD/EUR     04.02.2009    283000         283000   -218456.91          2141 
fceu            USDEUR QSA2     USD/EUR     11.02.2009    215000         498000   -166215.69          2185 
where OPEN_CONTRACTS is a running total of QUANTITY.
I have to SUM(TRADE_AMOUNT), but the sum must reset whenever OPEN_CONTRACTS goes to 0.
Is this possible without writing an external procedure ?

TIA
claudio

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 26 2009
Added on Mar 28 2009
8 comments
15,289 views