sql - Oracle Minus - From a list of values, how do I count ONLY non reversed values -
I have a list of payment transactions in a table, including payment reversal, payment reversals have not been flagged, so I It is to be assumed that if any deduction is equal to an existing transaction then it is a reversal
I should only count the transaction which was not reversed.
For example, from a list of transactions. 5 5 -5 (It is inversion for 5 transactions, hence a 5 transaction is still valid) 10 -10 (this is inverted for 10 transactions, so no 10 transactions are not valid) 15 15 15 -15 (This One is inverted for 15 transactions, so two 15 transactions are valid) 20
I want a list which
5 15 15 20
i There were four transactions that were not reversed.
Here are some test codes, my attempt does not work
Make tab check_minas (name_id number (4), trans number (4), well number (2)) ; Insert in check_minas values (1,1,5); Insert in check_minus values (1,2,5); Insert check_minus values (1,3, -5); Insert check_minus values (1,4, 10); Insert in check_mineas values (1,5, -10); Insert in check_minas values (1,6, 15); Insert check_mins in values (1,7, 15); Insert check_minus values (1,8, 15); Insert check_minas values (1,9, -15); Insert into check_minus values (1,10,20); Committed; - not using select_nid, val from check_minus where val & gt; 0 - Positive transactions and (name_id, val) (Choose val_l, val (val) val from check_minas where val & lt; 0 - negative transactions); - Select from zero name_id, check_manas where val & gt; 0 - Select positive name from the zero-check_minnas, select ABB (val) where the wall < 0 - Negative Transactions
Monthly work use a different set instead it Try:
on select_inumber () partition by name_id, name_id, val order by value), name_id, check_minas val from which val & gt; Select zero_number () name from 0 to zero by check_minus (name_id by partition, name_id, val order by val), name_id, abs (val) where val & lt; 0
generates this:
Random name_id val 1, 1, 20 2, 1, 5 2, 1, 15, 3, 1, 15
Comments
Post a Comment