Query not summing correctly when the two tables have different count of ids

is800025

New Member
Joined
Apr 8, 2014
Messages
5
Hi,

I have a query that tries to find the difference between 2 tables

Table1
Deal1 100
Deal1 200

Table2
Deal1 300

The query doesn't return 600 in 1 row for Deal1. It shows Deal1 twice and displays in column for Table2 300 twice. I have done summing and grouping / place distinct in front of Deal ID in the SQL. I thought by not displaying the two columns, but just result column would resolve the issue. But the problem remains. The join is 1 ( where the match of id is equal for both table.

Thank you in advance.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
To be sure I understand, in the current example the difference between the two tables for Deal 1 should be zero? Is that the answer you wish? If not please clarify.
 
Upvote 0
Ok. No issues.

If I were to do this, then I would follow the following steps.

Create an aggregate query for each table, summing on the amounts and grouping on the Deal field.

Now create a new query joining the two queries on the deals as your recordsets and create a new field and input an expression in the new field to sum the two amounts from the two queries.
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,407
Members
448,894
Latest member
spenstar

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