Subject | Wrong summation within join |
---|---|
Author | Frank |
Post date | 2005-01-08T21:50:13Z |
Hi,
I have a strange problem with the following clause:
-----------------
SELECT
a.ID, a.A1, a.A2,
SUM(b.B1 * b.B2) AS ValueB,
SUM(c.C1) AS ValueC
FROM
TableA a
LEFT JOIN TableB b ON b.AID = a.ID
LEFT JOIN TableC c ON c.AID = a.ID
GROUP BY
a.ID, a.A1, a.A2
------------------
The first sum is correctly calculated, but the second one is doubled.
When I remove the first aggragation, then the second value is correct!?
Any hints are greatly appreciated.
Thanks,
Frank
p.s. I use Firebird-1.5.2.4731
I have a strange problem with the following clause:
-----------------
SELECT
a.ID, a.A1, a.A2,
SUM(b.B1 * b.B2) AS ValueB,
SUM(c.C1) AS ValueC
FROM
TableA a
LEFT JOIN TableB b ON b.AID = a.ID
LEFT JOIN TableC c ON c.AID = a.ID
GROUP BY
a.ID, a.A1, a.A2
------------------
The first sum is correctly calculated, but the second one is doubled.
When I remove the first aggragation, then the second value is correct!?
Any hints are greatly appreciated.
Thanks,
Frank
p.s. I use Firebird-1.5.2.4731