5 pts.
0
Q:
DB2 SQL Confusion
I am failing to understand why the following won't work

SELECT m.index, SUM(d1.amt), SUM(d2.amt)
FROM master m,
detail d1,
detail d2
WHERE m.index = d1.index
AND m.index = d2.index
AND d2.qalif = 1
GROUP BY m.index

I wrote another sql that does work, I just don't understand why I get higher values on SUM(d2.amt) than I am expecting.
ASKED: Jan 9 2009  4:46 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
29340 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
To be able to help, I think we would need to know your table structures, and see what results are you getting and what results are you expecting with some example data.

When joining tables, if you do not write the appropriate join conditions, you could be duplicating rows.
Last Answered: Jan 9 2009  9:45 PM GMT by Carlosdl   29340 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0