self join introduces errors in count

joeblow2

Registered User.
Local time
Today, 12:28
Joined
Jun 28, 2008
Messages
39
I've included my tables, input data, output data and sql.
As you will notice the self join introduces errors in numbers in both Expr1 and Expr3.

I hope someone can see what is introducing the errors and how to fix it.
Thanks
 

Attachments

What I am doing is trying to get a combined solution set.
Basically I want to combine the results of these two queries:
Select Event_id,Question_id,Response,AgeGroup,Sum(Quantity)
From Event_line
Group by Event_id,Question_id,Response,AgeGroup
and
Select AgeGroup, Sum(Quantity)
From Event_line
Group by AgeGroup

individually run they give the correct result, however when combined by using a self-join,
I am getting double counting. See my attached Word document to see what I am getting as opposed to the desired result.
 

Users who are viewing this thread

Back
Top Bottom