I'm [guessing you] FiguredOut what [The.Problem] was.
SQL has just been really kicking my butt this week. My query has morphed into this:
SELECT DISTINCT A.RECIP_SSN_NBR,
FROM DSNP.PR01_T_RECIP_SYS A,
(SELECT RECIP_SSN_NBR, SUM(ANTY_PYMT_NET_AMT) AS TOTAL_2006
WHERE ANTY_PYMT_DT BETWEEN '2006-01-01' AND '2006-12-31'
GROUP BY RECIP_SSN_NBR) AS D,
(SELECT RECIP_SSN_NBR, SUM(ANTY_PYMT_NET_AMT) AS TOTAL_2007
WHERE ANTY_PYMT_DT BETWEEN '2007-01-01' AND '2007-12-31'
GROUP BY RECIP_SSN_NBR) AS E
Anyone see a logic problem here? The query works great when I run the sub-queries by themselves. Also it worked when I built in the sub-query for 2006. When I added the sub-query for 2007, I did not get an accurate sum. I received numerous rows for the same SSN with different dollar amounts. I should only get one record per SSN.