gpt4 book ai didi

sql - 如何加入 SQL Server 中的别名列?

转载 作者:行者123 更新时间:2023-12-04 02:50:34 27 4
gpt4 key购买 nike

我有以下问题。当输入为空时,我想用别名为“Code”的“yellow_code”列替换它。当我尝试在别名列 'Code' 上对另一个表上的 'GrantCode' 进行内部联接时,我收到以下错误描述:“无效的列名称 'Code'”。

无论如何要绕过这个?

最佳答案

SELECT 列别名实际上是最后应用到语句的东西,因此对于构成整个查询一部分的“向下”连接不可用。但是,如果从外部选择引用,您可以访问别名

例如

select my_code from
(
select 1 as my_code from ....
) x

关于sql - 如何加入 SQL Server 中的别名列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17863482/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com