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
How do I clean up my Terminal Server Licensing
SSIS error
Convert a T-SQL query to JET SQL aka Possible ALIAS Problems.
Script for truncating file and folder names
Upgrade from Win2003 R2 to Win 2008
Printer Server Shares
Loop through and delete an item from a combo box
How to create a domain-wide slideshow screensaver GPO by using pictures on each local machine ?
OLE registration error occurred
Auto-attach to process '[4152] w3wp.exe' on machine '[machine name]' failed. Error code 0x8013134b.