有没有办法重命名 CTE 查询中的输出缩写列?
Is there a way to rename output abreviated columns in a CTE query?
我需要重命名 CTE 查询的输出列。我想这可以用命令 AS
来完成,但我不知道放在哪里。
例如
with
table1 as (
select
atribute1 as a1
atribute2 as a2
from table2
),
table3
select
atribute3 as a3
from table4
)
select
table1.a1
table1.a2
table3.a3
from table1
join table 3 on table3.a3=table1.a1
;
这将给我一个 table 的输出,其列名如 a1
(第一列)、a2
(第二列)、a3
(第三列) ).我想将它们重命名为 a1
、a2
和 a3
.
谢谢!
您似乎想为最终结果集中的列添加别名。你可以这样做:
with
table1 as (...),
table3 as (...)
select
t1.a1 as first_column
t1.a2 as second_column
t3.a3 as third_column
from table1 t1
join table3 t3 on t3.a3 = t1.a1
我需要重命名 CTE 查询的输出列。我想这可以用命令 AS
来完成,但我不知道放在哪里。
例如
with
table1 as (
select
atribute1 as a1
atribute2 as a2
from table2
),
table3
select
atribute3 as a3
from table4
)
select
table1.a1
table1.a2
table3.a3
from table1
join table 3 on table3.a3=table1.a1
;
这将给我一个 table 的输出,其列名如 a1
(第一列)、a2
(第二列)、a3
(第三列) ).我想将它们重命名为 a1
、a2
和 a3
.
谢谢!
您似乎想为最终结果集中的列添加别名。你可以这样做:
with
table1 as (...),
table3 as (...)
select
t1.a1 as first_column
t1.a2 as second_column
t3.a3 as third_column
from table1 t1
join table3 t3 on t3.a3 = t1.a1