Thanks Jerry. Let me give some backgroud to what I am tryign to do here. I
am trying to compare two tables. Each table contains the same basic
information, only it may be different in amounts, accts, groups, or cusips.
I am comparing the two tables because I need to see what differences there
are or what cusips, groups, etc have changed. I already taken the two
tables and summed them to get a grand total per cusip, per group, per acct.
I am now trying to combine the two summed tables into one table. Wherever
there are null fields, I need 0's. It is almost running perfectly, but as I
said before, there are 30 duplicates being returned. If it was a common
error, there would be hundreds of duplicates. Some are going away, while
some are not. Here is an example of a duplication, they are exactly the
same.
BDSKACCT GRP CUSP SumOfPARVALUE SumOfPRINCOST
SumOfBOOKVALUE SumOfPARVALUE1 SumOfPRINCOST1 SumOfBOOKVALUE1
704 91 31394PTR4 20000000 20075000 20067716.1 20000000
20075000 20067715.4
704 91 31394PTR4 20000000 20075000 20067716.1 20000000
20075000 20067715.4
Here is the sql:
SELECT InTrader.BDSKACCT, InTrader.GRP, InTrader.CUSP, Sum(Nz(BOLT.PARVALUE,
0)) AS
SumOfPARVALUE, Sum(Nz(BOLT.PRINCOST, 0)) AS SumOfPRINCOST,
Sum(Nz(BOLT.BOOKVALUE, 0)) AS
SumOfBOOKVALUE, Sum(Nz(InTrader.PARVALUE, 0)) AS SumOfPARVALUE1,
Sum(Nz(InTrader.PRINCOST, 0)) AS SumOfPRINCOST1, Sum(Nz(InTrader.BOOKVALUE,
0)) AS
SumOfBOOKVALUE1
FROM BOLT RIGHT JOIN InTrader ON (BOLT.GRP = InTrader.GRP) AND
(BOLT.BDSKACCT = InTrader.BDSKACCT) AND (BOLT.CUSP = InTrader.CUSP)
GROUP BY InTrader.BDSKACCT, InTrader.GRP, InTrader.CUSP
UNION SELECT BOLT.BDSKACCT, BOLT.GRP, BOLT.CUSP, Sum(Nz(BOLT.PARVALUE, 0)) AS
SumOfPARVALUE, Sum(Nz(BOLT.PRINCOST, 0)) AS SumOfPRINCOST,
Sum(Nz(BOLT.BOOKVALUE, 0)) AS
SumOfBOOKVALUE, Sum(Nz(InTrader.PARVALUE, 0)) AS SumOfPARVALUE1,
Sum(Nz(InTrader.PRINCOST, 0)) AS SumOfPRINCOST1, Sum(Nz(InTrader.BOOKVALUE,
0)) AS
SumOfBOOKVALUE1
FROM BOLT LEFT JOIN InTrader ON (BOLT.GRP = InTrader.GRP) AND (BOLT.BDSKACCT
= InTrader.BDSKACCT) AND (BOLT.CUSP = InTrader.CUSP)
GROUP BY BOLT.BDSKACCT, BOLT.GRP, BOLT.CUSP
ORDER BY InTrader.BDSKACCT, InTrader.GRP, InTrader.CUSP;