我在 VB.NET 2008 下使用过这种类型的查询,但每次我运行它时,它总是给我一个致命错误,它告诉我声明我使用的 @variable。下面是示例代码:
select js.year, js.week, js.rem_balance,
case when js.rem_balance = 0
then @prev_rem_balance
else js.rem_balance
end as rem_balance_zero_or_prev,
@prev_rem_balance := js.rem_balance
from test_jos_stock js
inner join (SELECT @prev_rem_balance := 0) as t
order by year,week;