pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexey M Boltenkov <padrebolt@yandex.ru>
To: SQL Padawan <sql_padawan@protonmail.com>
To: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
Subject: Re: Strange sequences - how to construct?
Date: Sat, 23 Oct 2021 16:54:07 +0300
Message-ID: <c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru> (raw)
In-Reply-To: <tiUZZ67DYCE5aY4wDAfIXjzlghyf4ndcG2m7wWRd0Rq3rtyhd38iJ9fN2iG088MxWOQtEBlEbsLXzqq-RUYer6rXXfS67pjdwthg8YRIgQU=@protonmail.com>
References: <tiUZZ67DYCE5aY4wDAfIXjzlghyf4ndcG2m7wWRd0Rq3rtyhd38iJ9fN2iG088MxWOQtEBlEbsLXzqq-RUYer6rXXfS67pjdwthg8YRIgQU=@protonmail.com>

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.
>
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;

view thread (6+ messages)  latest in thread

Message-ID: <c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru>
Permalink:  ../c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru/
Also on:    postgresql.org/message-id/c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: padrebolt@yandex.ru, sql_padawan@protonmail.com, pgsql-novice@lists.postgresql.org
  Subject: Re: Strange sequences - how to construct?
  In-Reply-To: <c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru>
  References: <tiUZZ67DYCE5aY4wDAfIXjzlghyf4ndcG2m7wWRd0Rq3rtyhd38iJ9fN2iG088MxWOQtEBlEbsLXzqq-RUYer6rXXfS67pjdwthg8YRIgQU=@protonmail.com> <c2fae203-1e9f-bc35-5c0a-e684cdbdb56f@yandex.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox