我知道这是不可能的。但如果可能的话,我想通过任何间接方法来实现这一点。
实际上我想在下面添加查询以查看哪个抛出错误,视图中不允许子查询。
select T1.Code,
T1.month,
T1.value,
IfNull(T2.Value,0)+IfNull(T3.value,0) as value_begin
from (select *,@rownum := @rownum + 1 as rownum
from Table1
Join (SELECT @rownum := 0) r) T1
left join (select *,@rownum1 := @rownum1 + 1 as rownum
from Table1
Join (SELECT @rownum1 := 0) r) T2
on T1.code = T2.code
and T1.rownum = T2.rownum + 1
left join (select *,@rownum2 := @rownum2 + 1 as rownum
from Table1
Join (SELECT @rownum2 := 0) r) T3
on T1.code = T3.code
and T1.rownum = T3.rownum + 2
Order by T1.Code,T1.rownum
所以,我想我会将 Sub 查询作为单独的视图,但这又会引发视图中不允许变量的错误。请帮助克服这种情况。
提前感谢