为什么我无法访问子查询中的别名?

时间:2014-06-24 16:24:35

标签: sql

例如:

如果我尝试

     select job from (select ename as "name", job from emp) 

有效但

     select name from (select ename as "name", job from emp)

即使这不起作用。

     select a.name from (select ename as "name", job from emp) a

2 个答案:

答案 0 :(得分:1)

使用SQL Server 2008R2

SELECT
    A.Name

FROM
    (SELECT
        FormStatus AS [Name],
        FormStatusCodeID
    FROM
        CodeFormStatus) AS A

按预期工作。(使用现有表进行测试)

答案 1 :(得分:0)

select a.name from (select ename as "name", job from emp) as a