The following SQL results in some (not all) records being doubled in
the SUM()'d column. This occurs when I add in the LEFT OUTER JOIN'd
table. I can't for the life of me figure out why. Am I missing
something obvious?
SELECT
max(OB003.LTCUSTSN),
max(OB002.FGSTYLE),
max(OB002.FGLINWID),
max(OB002.FGCOLOR),
max(OB1002.CRDESC),
max(OB002.FGSHASPC),
sum(OB002.FGYARDS),
OB002.FGLOT#,
max(OB003.LTCOMMTS),
max(OB002.FGORDER#),
max(OB003.LTDUEDAT),
OB002.FGROLSTS,
max((days(CURRENT_DATE)-days(OB002.FGPRDDT)))
FROM
S10726EA.OBPRDDTA.OB002 OB002
INNER JOIN
S10726EA.OBPRDDTA.OB003 OB003
ON
OB002.FGLOT# = OB003.LTLOT#
LEFT OUTER JOIN
S10726EA.OBPRDDTA.OB1002 OB1002
ON
OB002.FGCOLOR = OB1002.CRCOLOR
WHERE
OB002.FGROLSTS in (8,10)
AND
OB002.FGQUALTY in ('FS', 'RW')
AND
((OB003.LTLOTSTS between 55 and 61) OR (OB003.LTLOTSTS = 35 AND
OB003.LTCOMPLT = 'Y'))
AND
OB002.FGPRDDT <= (DATE('03/26/2008') - 90 DAYS)
GROUP BY
OB002.FGLOT#, OB002.FGROLSTS
jmoseby_@_elasticfabrics.com - 27 Mar 2008 15:15 GMT
>The following SQL results in some (not all) records being doubled in
>the SUM()'d column. This occurs when I add in the LEFT OUTER JOIN'd
>table. I can't for the life of me figure out why. Am I missing
>something obvious?
<snip>
Nevermind,
The answer is "YES" I missed something obvious. Duplicate records in
the LEFT OUTER JOIN'd table. Duh.