为什么这个select语句没有设置变量呢?

时间:2010-02-02 05:14:04

标签: sql sql-server-2005

我正在写这样的存储过程..

declare @avg float
set @avg = select avg(rating) from videorating where videoid = 4

我能这样写吗?我可以将值存储在@avg中吗?

1 个答案:

答案 0 :(得分:3)

我会写它

declare @avg float
select @avg=avg(rating) from videorating where videoid = 4