Hello,
I am using the following sql statment below in access to perform a full outer join. And although it runs and produces results, there is something really funny about the results. Some records values almost quadupled in amount!
here is the code:
SELECT A.x,A.z, Sum(a.y), Sum(A.y1),Sum(B.v), Sum(B.v1)
FROM A_tbl AS A LEFT JOIN B_tbl AS B
ON (A.P=B.P) AND (A.[N]=B.[N])
GROUP BY A.x, A.y
ORDER BY A.x, A.y
Union All
SELECT B.x,B.z, Sum(a.y), Sum(A.y1),Sum(B.v), Sum(B.v1)
FROM A_tbl AS A Right JOIN B_tbl AS B
ON (A.P=B.P) AND (A.[N]=B.[N])
GROUP BY B.x, B.y
Union All
SELECT A.x,A.z, Sum(a.y), Sum(A.y1),Sum(B.v), Sum(B.v1)
FROM A_tbl AS A INNER JOIN B_tbl AS B
ON (A.P=B.P) AND (A.[N]=B.[N])
GROUP BY A.x, A.y
Does anyone know if I need to perform the inner join? Since both my left and right joins are also bring those records that match both tables.
And Does anyone know why my numbers are way off? For example,when the query should return 10 for SUM(A.y1) it returns 34, etc.
Thank You,
AV
I am using the following sql statment below in access to perform a full outer join. And although it runs and produces results, there is something really funny about the results. Some records values almost quadupled in amount!
here is the code:
SELECT A.x,A.z, Sum(a.y), Sum(A.y1),Sum(B.v), Sum(B.v1)
FROM A_tbl AS A LEFT JOIN B_tbl AS B
ON (A.P=B.P) AND (A.[N]=B.[N])
GROUP BY A.x, A.y
ORDER BY A.x, A.y
Union All
SELECT B.x,B.z, Sum(a.y), Sum(A.y1),Sum(B.v), Sum(B.v1)
FROM A_tbl AS A Right JOIN B_tbl AS B
ON (A.P=B.P) AND (A.[N]=B.[N])
GROUP BY B.x, B.y
Union All
SELECT A.x,A.z, Sum(a.y), Sum(A.y1),Sum(B.v), Sum(B.v1)
FROM A_tbl AS A INNER JOIN B_tbl AS B
ON (A.P=B.P) AND (A.[N]=B.[N])
GROUP BY A.x, A.y
Does anyone know if I need to perform the inner join? Since both my left and right joins are also bring those records that match both tables.
And Does anyone know why my numbers are way off? For example,when the query should return 10 for SUM(A.y1) it returns 34, etc.
Thank You,
AV