SQL Server Update Group by

前端 未结 3 1604
逝去的感伤
逝去的感伤 2020-11-30 08:13

I\'m trying to execute this on MS-SQL but returns me an error just at the Group by line

update #temp
Set Dos=Count(1)
From Temp_Table2010 s
where Id=s.Total          


        
3条回答
  •  盖世英雄少女心
    2020-11-30 09:05

    You can't use an aggregate in an UPDATE query, for starters - though you didn't include the error message in your original question, I suspect that's what it's telling you.

    You'll need to calculate the aggregate before your update and store the results in a temp table, and then join to that table to do your update.

提交回复
热议问题