with [dct] as
(
select [boxid], [operator], [palletid], count([newstamp]) [stampscount]
from [ViewDCTData]
group by [boxid], [operator], [palletid]
)
update [b]
set
[b].[packdate] = getdate(),
[b].[operator] = [dct].[operator],
[b].[palletid] = [dct].[palletid],
[b].[stamps] = [dst].[stampscount]
from [boxes] [b]
inner join [dct] on [dct].[boxid] = [b].[id]
Ошибка:
Msg 4104, Level 16, State 1, Line 12
The multi-part identifier "dst.stampscount" could not be bound.
Почему нельзя использовать функцию агрегации в таком запросе?