Given 2 tables
CustomerActivity
CustomerId, ActivityId, CreatedOnDate
1, 1, 8/1/2010
1, 2, 8/15/2010
2, 1, 7/24/2010
2, 2, 8/15/2010
TempUpdateTable
CustomerId, RecentActivityDate
1, NULL
2, NULL
How do I fill in the NULLs in TempUpdateTable using the CustomerActivity table?
My first attempt didn’t pan out:
UPDATE [TempUpdateTable]
SET RecentActivityDate =
(SELECT MAX(CreatedOnDate) FROM CustomerActivity CA WHERE CA.CustomerId = CustomerId )
Thanks,
rod.
You can also try this: