Match off one duplicate

RMS123

Board Regular
Joined
Jun 1, 2016
Messages
62
Hi there,

I was wondering if anyone had a better solution for dealing with duplicates.

I would like to Match off One duplicate and show the other in my results.

Table 1:

Book1
EFG
1TRACEACCOUNTAMOUNT
21111100
32222200
43333300
54444400
65555500
Sheet2


Table 2:

Book1
ABC
1TRACEACCOUNTAMOUNT
21111100
32222200
43333300
54444400
65555500
75555500
Sheet2



Desired Result:

Book1
IJK
1TRACEACCOUNTAMOUNT
25555500
Sheet2


Is the only way is to group and left join on trace, account, amount and count or is there an optimal way?
Code:
[/COLOR]SELECT Table1.TRACE, Table1.ACCOUNT, Table1.AMOUNT, Count(Table1.AMOUNT) AS CountOfAMOUNT
FROM Table1
GROUP BY Table1.TRACE, Table1.ACCOUNT, Table1.AMOUNT;

SELECT Table2.TRACE, Table2.ACCOUNT, Table2.AMOUNT, Count(Table2.AMOUNT) AS CountOfAMOUNT
FROM Table2
GROUP BY Table2.TRACE, Table2.ACCOUNT, Table2.AMOUNT;

SELECT Table2_Count.*
FROM Table2_Count LEFT JOIN Table1_Count ON (Table2_Count.TRACE = Table1_Count.TRACE) AND (Table2_Count.ACCOUNT = Table1_Count.ACCOUNT) AND (Table2_Count.AMOUNT = Table1_Count.AMOUNT) AND (Table2_Count.CountOfAMOUNT = Table1_Count.CountOfAMOUNT)
WHERE (((Table1_Count.CountOfAMOUNT) Is Null));

Result:

Book1
MNOP
2TRACEACCOUNTAMOUNTCountOfAMOUNT
355555002
Sheet2



Thank you for any help on this, I am kind of a newbie with Access so any suggestions would be great!:)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Simply Go to Data Tab -> Remove Duplicate, select the column/columns on which duplicate criteria is based on.


Final Table would be without duplicate
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top