Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 4:34 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Thu, Jan 20, 2022 at 4:32 PM Ken Tanzer wrote: > >> >> >> On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston < >> david.g.johns...@gmail.com> wrote: >> >>> You can always write: >>> >>> CREATE VIEW cte_view

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 4:32 PM Ken Tanzer wrote: > > > On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> You can always write: >> >> CREATE VIEW cte_view AS >> WITH cte AS (...) >> SELECT * FROM cte; >> >> And then incorporate that into any queries tha

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Ken Tanzer
On Thu, Jan 20, 2022 at 8:46 AM David G. Johnston < david.g.johns...@gmail.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 s

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thu, Jan 20, 2022 at 7:42 AM Avi Weinberg wrote: > > > Thanks David for the reply, but my question was a little different. > > I know I can have multiple CTE queries like you showed, but I want to > have one single WITH query, and use it in multiple queries, not just by one > query the directl

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Johannes Graën
On 20/01/2022 15.42, Avi Weinberg wrote: Thanks David for the reply, but my question was a little different. I know I can have multiple CTE queries like you showed, but I want to have one single WITH query, and use it in multiple queries, not just by one query the directly proceed the CTE.

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Josef Šimánek
čt 20. 1. 2022 v 13:48 odesílatel Avi Weinberg 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 ….; > > > &g

RE: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Avi Weinberg
if I have two queries that wants to use it? Thanks From: David G. Johnston [mailto:david.g.johns...@gmail.com] Sent: Thursday, January 20, 2022 2:58 PM To: Avi Weinberg Cc: pgsql-general@lists.postgresql.org Subject: Re: Multiple SELECT statements Using One WITH statement On Thursday, January

Re: Multiple SELECT statements Using One WITH statement

2022-01-20 Thread David G. Johnston
On Thursday, January 20, 2022, Avi Weinberg wrote: > Hi, > > > > 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

Multiple SELECT statements Using One WITH statement

2022-01-20 Thread Avi Weinberg
Hi, 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 ; IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain