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

  • SEARCH
  • Home
  • 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 88483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:34:01+00:00 2026-05-10T22:34:01+00:00

I have a table of transactions which will occasionally have duplicate entries. If/When an

  • 0

I have a table of transactions which will occasionally have duplicate entries. If/When an admin finds these duplicate entries, they will reverse the transactions, therefore creating a negative value (but the original duplicate still remains due to regulatory requirements). I’d like to create a SQL query (and use Crystal Reports) to make a report for the admins to easily find duplicate transactions. Due to the mass quantity of transactions, I’d like to make it easier for them by disregarding transactions that they have already reversed.

Here’s an example of what I’d like to do:

Transaction Date ; Transaction Qty ; Transaction Value ; Reversal

1/1/08    ; 14    ;    70.00    ; N 1/1/08    ; 14    ;    70.00    ; N 1/1/08    ; -14   ;    -70.00   ; Y 2/1/08    ; 17    ;    89.00    ; N 2/15/08   ; 18    ;    95.00    ; N 2/15/08   ; 18    ;    95.00    ; N 3/1/08    ; 11    ;    54.00    ; N 3/1/08    ; -11   ;    -54.00   ; Y 3/1/08    ; 11    ;    54.00    ; N 3/1/08    ; 11    ;    54.00    ; N 3/1/08    ; 11    ;    54.00    ; N 

Ideally, if I ran my ‘desired’ query on the table above, I would receive the following result:

Transaction Date ; Transaction Qty ; Transaction Value ; Count

2/15/08    ; 18    ;    95.00    ; 2 3/1/08     ; 11    ;    54.00    ; 3 

Does that make sense? I’ve already figured out how to write the query to give me a count of duplicates, but I can’t figure out how to exclude duplicate records which have been ‘backed out’ already. Any help would be greatly appreciated!

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:34:02+00:00Added an answer on May 10, 2026 at 10:34 pm

    How about:

    select dt, abs(qty), abs(val),        sum(case when reversal='Y' then -1 else 1 end) as count from transactions group by dt, abs(qty), abs(val) having sum(case when reversal='Y' then -1 else 1 end) > 1; 

    I have just tested it in Oracle and it works:

    create table transactions ( dt date , qty number , val number , reversal varchar2(1) );  insert into transactions values (to_date('1/1/08','mm/dd/yy')    , 14    ,    70.00    , 'N'); insert into transactions values (to_date('1/1/08','mm/dd/yy')    , 14    ,    70.00    , 'N'); insert into transactions values (to_date('1/1/08','mm/dd/yy')    , -14   ,    -70.00   , 'Y'); insert into transactions values (to_date('2/1/08','mm/dd/yy')    , 17    ,    89.00    , 'N'); insert into transactions values (to_date('2/15/08','mm/dd/yy')   , 18    ,    95.00    , 'N'); insert into transactions values (to_date('2/15/08','mm/dd/yy')   , 18    ,    95.00    , 'N'); insert into transactions values (to_date('3/1/08','mm/dd/yy')    , 11    ,    54.00    , 'N'); insert into transactions values (to_date('3/1/08','mm/dd/yy')    , -11   ,    -54.00   , 'Y'); insert into transactions values (to_date('3/1/08','mm/dd/yy')    , 11    ,    54.00    , 'N'); insert into transactions values (to_date('3/1/08','mm/dd/yy')    , 11    ,    54.00    , 'N'); insert into transactions values (to_date('3/1/08','mm/dd/yy')    , 11    ,    54.00    , 'N');  SQL> select dt, abs(qty), abs(val),   2         sum(case when reversal='Y' then -1 else 1 end) as count   3  from transactions   4  group by dt, abs(qty), abs(val)   5  having sum(case when reversal='Y' then -1 else 1 end) > 1;  DT            ABS(QTY)   ABS(VAL)      COUNT ----------- ---------- ---------- ---------- 15-FEB-2008         18         95          2 01-MAR-2008         11         54          3 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am storing transactions in a table. These transactions have an ID which relates
I have a table Transactions(store_id, item_id, price). I want to find store_id's which sell
(I am using PostgreSQL) I have a table which stores transactions to an account.
We have a table of transactions which is structured like the following : TranxID
I have two tables which have some transactional stuff stored in them. There will
I have a table transaction which has duplicates. i want to keep the record
I have a table schema which is essentially a bunch of transaction info with
I have a table: create table Transactions(Tid int, amt int) With 5 rows: insert
I have a table (dump) with transactions, and I want to list the total
I have a declarative table defined like this: class Transaction(Base): __tablename__ = transactions id

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.