我从参考笔记中发现了以下查询,并且可以看到将lineitem
表命名为l1
,并将lineitem
表命名为l2
。
select avg(l_extendedprice) from lineitem l1
where l_extendedprice =
(select min(l_extendedprice) from lineitem l2
where l1.l_orderkey = l2.l_orderkey);
这是有效的别名方法,无需显式使用AS
吗?如果这不是Postgres中的别名,这是什么约定?
答案 0 :(得分:2)
SQL标准允许您使用带或不带AS
的别名。
区别在于,如果没有AS
,则不能使用PostgreSQL关键字作为别名,请参见the documentation。因此,始终使用AS
更为安全。