I'm trying this for returning business days, but I don´t understand s.a
and s(a)
in this query:
SELECT dia
FROM (
SELECT ('2012-08-01'::date + s.a * '1 day'::interval) AS dia
FROM generate_series(0, '2012-08-31'::date - '2012-08-01'::date, 1) AS s(a)
) foo
WHERE EXTRACT(DOW FROM dia) BETWEEN 1 AND 5
EXCEPT
SELECT feriado_data FROM teste.feriado;
Could someone explain it for me?
s
in s(a)
is a table alias given to the set returned by generate_series
and the a
in s(a)
is the alias given to its only column.
Refer to table expression docs and scroll to "Another form of table aliasing gives temporary names to the columns of the table" for full details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With