Microsoft
Software
Hardware
Network
Question : aggregate in the set list of an UPDATE statement.
Hello, I get the following error with my statement below:
An aggregate may not appear in the set list of an UPDATE statement.
How can I fix the statement?
Update a
set LastComment = MAX(b.created)
from ReviewComments b
INNER JOIN #Temp a
ON a.[ReviewId] = b.[ReviewId]
Answer : aggregate in the set list of an UPDATE statement.
This should do:
Update a
set LastComment = b.created
from #Temp a
INNER JOIN ( SELECT [ReviewId], MAX(created) created FROM ReviewComments
GROUP BY [ReviewId]) b
ON a.[ReviewId] = b.[ReviewId]
Random Solutions
Delete duplicate records
Error No Windows Terminal Server Name is set up in Business Portal purchasing
Drag n Drop File Upload
Windows/Microsoft Updates all fail for new install of Win XP Pro
Outlook Distribution Lists
Locking down a 2003 Terminal Server with a 2008 GPO
Count and display the number of times the same entry appears
how to format 3 decimal places in spreadsheet control cells
Dialog box for making the user select the printer
Access 2007 text box using Sum function won't update until focus leaves Access window