Re: Multiple SELECT statements Using One WITH statement - Mailing list pgsql-general

From Josef Šimánek
Subject Re: Multiple SELECT statements Using One WITH statement
Date
Msg-id CAFp7Qwp1Ymz0ZD7z2vN7D+3+xd4Z8tFXK+PSbD2XNePdT1GZmA@mail.gmail.com
Whole thread Raw
In response to Multiple SELECT statements Using One WITH statement  (Avi Weinberg <AviW@gilat.com>)
List pgsql-general
čt 20. 1. 2022 v 13:48 odesílatel Avi Weinberg <AviW@gilat.com> napsal:
>
> Hi,
Hello!
>
>
> Can I have multiple select statements using one WITH statement?
>
>
>
> WITH t AS (
>
>     Select A, B from …
>
> )
>
> SELECT A into tableA FROM t where ….;
>
>
>
> SELECT B into tableB FROM t where ….;
>

I think it is not possible that way. Instead you can "cache" the query
result into a temporary table. CREATE TEMPORARY TABLE  ... ON COMMIT
DROP could be useful here. There is simple example mentioned in this
(https://stackoverflow.com/a/52384424/319233) stackoverflow answer.
>
> IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information
whichis confidential or privileged. If you are not the intended recipient, please inform the sender immediately and
deletethis email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person. 



pgsql-general by date:

Previous
From: Avi Weinberg
Date:
Subject: RE: Multiple SELECT statements Using One WITH statement
Next
From: Johannes Graën
Date:
Subject: Re: Multiple SELECT statements Using One WITH statement