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!