在case when中实现变量赋值
我想让orderid等于10253时,让@i的值加1,可是要报错:
use northwind
go
declare @i int
set @i=1;
select case orderid when 10253 then @i=@i+1 else 1 end from orders
请问用select语句怎么实现orderid等于10253时,让@i的值加1?
谢谢
------解决方案--------------------select @i = case orderid when 10253 then @i+1 else 1 end from orders
------解决方案--------------------use northwind
go
declare @i int
set @i = 1
select @i = @i + 1 from orders where orderid = 10253