I described the tables wrong, let me try this again.T1[T1ID], [TOTAL], [DATE]1, 10, '04/03'2008'1, 8, '04/02'2008'1, 6, '04/01'2008'2, 11, '04/03'2008'2, 10, '04/02'2008'2, 1, '04/01'2008'3, 10, '04/03'2008'3, 1, '04/02'2008'3, 0, '04/01'2008'/* This is the result I would expect if I ran a query that would give me, for each T1ID in table 1 the difference between the total of 04/03/2008 and 04/02/2008 */T2[T1ID], [RESULT]1, 22, 13, 9
Now, I almost have it running using visakh16's tip, except I'm having trouble specifying the T1ID correctly. Here's what I have:UPDATE T2SET RESULT = res.DIFF FROM T1 INNER JOIN(SELECT (a.TOTAL - b.TOTAL) as DIFFFROM T1 aINNER JOIN T1 bON a.DATE='04/03/2008' AND b.DATE='04/02/2008') resON T2.T1ID = res.T1ID
Any idea what I am doing wrong?