From: | Alexey M Boltenkov <padrebolt(at)yandex(dot)ru> |
---|---|
To: | SQL Padawan <sql_padawan(at)protonmail(dot)com>, "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Strange sequences - how to construct? |
Date: | 2021-10-23 13:59:19 |
Message-ID: | 6b774981-3126-0606-5a17-59fb125a213c@yandex.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
On 10/22/21 22:29, SQL Padawan wrote:
>
> Good afternoon to everybody.
>
> I wish to construct some weird sequences.
>
> 1
> 1
> 2
> 2
> &c.
>
> and with 3 ones, 4 ones... &c.
>
> Now, I know how to do a simple
> 1
> 2
> 3
> 4
>
> using both GENERATE_SERIES and using a RECURSIVE CTE.
>
> What I would like is to be able to construct my specified sequences
> using *_both_* GENERATE_SERIES *_and_* RECURSIVE CTEs.
>
> Regards,
>
> SQL Padawan!
>
>
>
>
> Sent with ProtonMail <https://protonmail.com/> Secure Email.
>
Or may be you want something strange?
*_both_* GENERATE_SERIES *_and_* RECURSIVE CTEs: with recursive x as (
select generate_series(1, 5) x union all select x + 1 from x where x = x
- 1) select unnest(array[x, x]) x from x;
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-10-23 14:42:21 | Re: Issue with pg_basebackup v.11 |
Previous Message | Alexey M Boltenkov | 2021-10-23 13:54:07 | Re: Strange sequences - how to construct? |
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Rychlewski | 2021-10-26 18:47:50 | nested loop joins |
Previous Message | Alexey M Boltenkov | 2021-10-23 13:54:07 | Re: Strange sequences - how to construct? |