Reputation: 2119
In a presentation on Window functions made by EDB (https://youtu.be/XO1WnmJs9RI), they start out with what they call the simplest form of a window function as this:
SELECT *
FROM generate_series(1, 10) AS f(x);
What is the meaning of the AS f(x)
clause at the end of this statement? I searched the documentation under both the SELECT command and the window function, and cannot find any explanation for this syntax. I know that the AS
portion allows us to rename the column, but I am clueless on the f(x)
part.
Upvotes: 1
Views: 402
Reputation: 1270361
This is simply a table alias that defines the result of generate_series()
:
f
.x
.The as
is optional (and I leave it out of table aliases).
So, you could write the select
as:
select f.x
This is handy when you want to use the value for other purposes, such as calculations and join
s.
Upvotes: 4