Surya sasidhar
Surya sasidhar

Reputation: 30303

Why doesn't this select statement, setting a variable, work?

I am writing a stored procedure like this..

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

Can I write it like this? Can I store the value in @avg?

Upvotes: 1

Views: 79

Answers (1)

Michael Todd
Michael Todd

Reputation: 17051

I would write it

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

Upvotes: 3

Related Questions