我想了解,在不同地方使用子查詢時,SQL中特定列的範圍是什麼。例如SQL,子查詢中列的範圍
select (case(val)
when 1 then 'one'
when 2 then 'two'
else 'something else'
end) as description, val
from (select 1 as val from dual);
該查詢的VAL在SELECT語句中使用,並且結果是
Description | Val
-------------------
one | 1
,但有以下查詢
select (case(val)
when 1 then 'one'
when 2 then 'two'
else 'something else'
end) as description,
(select 1 from dual) as val
from dual;
繼引發錯誤(在Oracle)
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 263 Column: 14
爲什麼val在後面的例子中不可用,這背後的技術原因是什麼?