DonkeyKong
Registered User.
- Local time
- Today, 09:20
- Joined
- Jan 24, 2013
- Messages
- 61
My SUMs are getting screwed up...
If I do this I get the correct value:
SELECT HOLDERS.CUSIP, Sum(HOLDERS.ORIGINAL_FACE) AS [ORIGINAL FACE]
FROM HOLDERS INNER JOIN TEMP_HOLD ON TEMP_HOLD.CUSIP = HOLDERS.CUSIP WHERE HOLDERS.CUSIP IS NOT NULL
GROUP BY HOLDERS.CUSIP
ORDER BY HOLDERS.CUSIP
But if I do this, my value gets thrown waaay off:
SELECT HOLDERS.CUSIP, Sum(HOLDERS.ORIGINAL_FACE) AS [ORIGINAL FACE]
FROM (HOLDERS INNER JOIN TEMP_HOLD ON TEMP_HOLD.CUSIP = HOLDERS.CUSIP) INNER JOIN [300_HOLDERS] ON TEMP_HOLD.CUSIP = [300_HOLDERS].CUSIP
WHERE HOLDERS.CUSIP IS NOT NULL
GROUP BY HOLDERS.CUSIP
ORDER BY HOLDERS.CUSIP
Why is this happening? I know it is something with my join. Is there a way I can fix this without making another seperate query? Thanks.
If I do this I get the correct value:
SELECT HOLDERS.CUSIP, Sum(HOLDERS.ORIGINAL_FACE) AS [ORIGINAL FACE]
FROM HOLDERS INNER JOIN TEMP_HOLD ON TEMP_HOLD.CUSIP = HOLDERS.CUSIP WHERE HOLDERS.CUSIP IS NOT NULL
GROUP BY HOLDERS.CUSIP
ORDER BY HOLDERS.CUSIP
But if I do this, my value gets thrown waaay off:
SELECT HOLDERS.CUSIP, Sum(HOLDERS.ORIGINAL_FACE) AS [ORIGINAL FACE]
FROM (HOLDERS INNER JOIN TEMP_HOLD ON TEMP_HOLD.CUSIP = HOLDERS.CUSIP) INNER JOIN [300_HOLDERS] ON TEMP_HOLD.CUSIP = [300_HOLDERS].CUSIP
WHERE HOLDERS.CUSIP IS NOT NULL
GROUP BY HOLDERS.CUSIP
ORDER BY HOLDERS.CUSIP
Why is this happening? I know it is something with my join. Is there a way I can fix this without making another seperate query? Thanks.