I am trying to write an update statement based on an aggregate and it will not let me. Please find below the SQL.
update pp
Set ReleaseOfInformationIndicatorDate = IsNull(max(pv.visit),GETDATE())
from PatientProfile pp
inner join patientvisit pv on pp.PatientProfileId = pv.PatientProfileId
and this is the error message:
Server: Msg 157, Level 15, State 1, Line 2
An aggregate may not appear in the set list of an UPDATE statement.
Can someone tell me how to get round this please?
Many thanks
update pp
Set ReleaseOfInformationIndicatorDate = IsNull(max(pv.visit),GETDATE())
from PatientProfile pp
inner join patientvisit pv on pp.PatientProfileId = pv.PatientProfileId
and this is the error message:
Server: Msg 157, Level 15, State 1, Line 2
An aggregate may not appear in the set list of an UPDATE statement.
Can someone tell me how to get round this please?
Many thanks