Re: Strange sequences - how to construct? - Mailing list pgsql-novice

From Alexey M Boltenkov
Subject Re: Strange sequences - how to construct?
Date
Msg-id c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru
Whole thread Raw
In response to Strange sequences - how to construct?  (SQL Padawan <sql_padawan@protonmail.com>)
List 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 Secure Email.

GENERATE_SERIES: select unnest(array[x, x]) x from generate_series(1, 5) x;

RECURSIVE CTE: with recursive x as ( select 1 x union all select x + 1 from x where x < 5) select unnest(array[x, x]) x from x;

pgsql-novice by date:

Previous
From: TIM CHILD
Date:
Subject: Re: Strange sequences - how to construct?
Next
From: Alexey M Boltenkov
Date:
Subject: Re: Strange sequences - how to construct?