Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 297207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:37:07+00:00 2026-05-12T06:37:07+00:00

I have a list of payment transactions in a table. That include payment reversals.

  • 0

I have a list of payment transactions in a table. That include payment reversals. The Payment reversals are not flagged, so I have to infer that if a deduction is equal to an existing transaction it is a reversal

I want a count of only the transactions that were not reversed.

E.g From a list of transactions amounts.

5
5
-5 (This is reversal for one 5 transaction, so one 5 transaction is still valid)
10
-10 (This is reversal for one 10 transaction, so no 10 transactions are valid )
15
15
15
-15 (This is reversal for one 15 transaction, so two 15 transactions are valid )
20

I want a list which is

5
15
15
20

i.e I had four transactions which were not reversed.

Here is some test code, my attempt did not work.

CREATE TABLE check_minus
(
name_id NUMBER(4),
trans NUMBER(4),
val NUMBER(2)
);

insert into  check_minus values (1,1,5);
insert into  check_minus values (1,2,5);
insert into  check_minus values (1,3,-5);
insert into  check_minus values (1,4,10);
insert into  check_minus values (1,5,-10);
insert into  check_minus values (1,6,15);
insert into  check_minus values (1,7,15);
insert into  check_minus values (1,8,15);
insert into  check_minus values (1,9,-15);
insert into  check_minus values (1,10,20);
commit;

-- using  not in
select name_id, val from check_minus
    where val > 0  -- positive transactions
    and (name_id, val) not in 
    (
    select name_id, abs(val) val from check_minus
    where val < 0 -- negative transactions
    );

-- using  minus
select name_id, val from check_minus
    where val > 0  -- positive transactions
 minus 
select name_id, abs(val) from check_minus
    where val < 0  -- negative transactions
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:37:07+00:00Added an answer on May 12, 2026 at 6:37 am

    Minus operations use distinct sets. Try this instead:

    select row_number() over (partition by name_id, val order by name_id, val), name_id, val 
    from check_minus
    where val > 0
      minus
    select row_number() over (partition by name_id, val order by name_id, val), name_id, abs(val) 
    from check_minus
    where val < 0
    

    It produces:

    RowNum Name_Id   Val
    1,     1,        20
    2,     1,        5
    2,     1,        15
    3,     1,        15
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of articles on the page in table and i want to
i have list of rows that user select and i want to delete them,
I have a form that once you select from a drop-down list and select
i have put that url http://pvpcoach.com/notification.php in Instant Payment Notification setting in my profile
I have a radio list to pick a payment value. When you choose the
I have a list which shows all the orders that have been placed with
I have some code in JSP as below: <c:iterate name=list id=payment index=idx> <tr class=gRowEven
I have one test account that has exactly two purchases in its transaction history.
I have following code to insert data into GiftCouponPayment table and Payment table. This
I have a problem with a query: I have a table with a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.