Re: TSQL To Postgres - Unpivot/Union All

From: Anthony Apollis <anthony(dot)apollis(at)gmail(dot)com>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: TSQL To Postgres - Unpivot/Union All
Date: 2023-07-20 15:47:08
Message-ID: CAJyMCY+97Lg=EANU6g5iioj0ay+FMssws2Dfjb1vV9UGUjG39w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

CREATE TEMP TABLE temp_FieldFlowsFact (
Account varchar(20),
"Calendar day" DATE,
"Financial year" varchar(5),
Period varchar(8),
"Period type" varchar(10),
Metric varchar(50),
"Metric Value" float
)
It was created as a temp table in SQLServer, but it does not have to be in
Postgres. Thanks

On Thu, 20 Jul 2023 at 16:51, Geoff Winkless <pgsqladmin(at)geoff(dot)dj> wrote:

> On Thu, 20 Jul 2023 at 15:28, Anthony Apollis <anthony(dot)apollis(at)gmail(dot)com>
> wrote:
> > I am attaching my TSQL and Postgres SQL:
>
> You're still missing some CREATEs, for example for temp_FieldFlowsFact.
>
> Even assuming your columns list is correct, I would still (and as a
> matter of habit) include the target column list in your INSERT
> statements, if only to make your own life easier, but especially
> because any later changes to the tables could end up shifting the
> position of the columns.
>
> Certainly it will be easier for anyone else trying to disentangle the SQL
> later.
>
> As an aside, can you clarify whether you mean temporal tables (and are
> you using a temporal tables extension)? Or should that read
> "temporary"?
>
> Geoff
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chuck Davis 2023-07-20 16:44:35 Re: My 1st JDBC and PostgreSQL
Previous Message Luca Ferrari 2023-07-20 15:31:27 Re: suggestion about time based partitioning and hibernate

Browse pgsql-sql by date

  From Date Subject
Next Message JORGE MALDONADO 2023-07-25 14:35:45 Declaring a constant or variable in a query
Previous Message Thomas Kellerer 2023-07-20 15:07:31 Re: Fwd: TSQL To Postgres - Unpivot/Union All