Re: Multiple SELECT statements Using One WITH statement

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Avi Weinberg <AviW(at)gilat(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Multiple SELECT statements Using One WITH statement
Date: 2022-01-20 23:32:10
Message-ID: CAD3a31X8WPvxiigFObf46Eui4aGF_c6HBmNTQpqN7zi5Hhqpgg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> You can always write:
>
> CREATE VIEW cte_view AS
> WITH cte AS (...)
> SELECT * FROM cte;
>
> And then incorporate that into any queries that require the results of
> said CTE.
>
>
Is there any advantage to still using a CTE inside the view definition, and
then selecting it? Instead of just

CREATE VIEW cte_view AS
(...);

Just curious, in case I'm missing something!

Cheers,
Ken

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-01-20 23:34:15 Re: Multiple SELECT statements Using One WITH statement
Previous Message Adrian Klaver 2022-01-20 20:51:55 Re: psql does not provide proper response