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
Backspace not working
Delete from Access form certain records in a table that relate to another table's field
Windows form dialog box Refresh parent
Modify a PARAM tag value within C#
Leading zero from number to Concatenated filed
Installing Windows XP on a laptop with Vista
Visual Basic .net 2008 desktop app crashes on startup on Windows 7 64 Bit
Format a portion of text box in bold
SQL datetime issue: The following 2 sections of code produce different results.
Windows 7 Backup