Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AS s(a) vs. AS a

1 view
Skip to first unread message

Thalis Kalfigkopoulos

unread,
Oct 11, 2012, 6:39:18 PM10/11/12
to
Hi all.

I see in the docs the following:
SELECT current_date + s.a AS dates FROM generate_series(0,14,7) AS s(a);

Trying it as:
SELECT current_date + a AS dates FROM generate_series(0,14,7) AS a;

yields exactly the same result.

Does the finer granularity/expressiveness offer some extra
functionality in some cases or is it a matter of style?

regards,
--Thalis


--
Sent via pgsql-general mailing list (pgsql-...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Tom Lane

unread,
Oct 11, 2012, 10:18:21 PM10/11/12
to
Thalis Kalfigkopoulos <tkal...@gmail.com> writes:
> I see in the docs the following:
> SELECT current_date + s.a AS dates FROM generate_series(0,14,7) AS s(a);

> Trying it as:
> SELECT current_date + a AS dates FROM generate_series(0,14,7) AS a;

> yields exactly the same result.

> Does the finer granularity/expressiveness offer some extra
> functionality in some cases or is it a matter of style?

IIRC, it's important for functions returning composite types. For a
function returning scalar, "AS a" is equivalent to "AS a(a)".

regards, tom lane
0 new messages