Re: TSQL To Postgres - Unpivot/Union All

2023-07-20 Thread Anthony Apollis
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

Re: TSQL To Postgres - Unpivot/Union All

2023-07-20 Thread Geoff Winkless
On Thu, 20 Jul 2023 at 15:28, Anthony Apollis 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 INSE

Re: TSQL To Postgres - Unpivot/Union All

2023-07-20 Thread Geoff Winkless
On Thu, 20 Jul 2023 at 13:17, Anthony Apollis wrote: > The Postgres i used: INSERT INTO temp_FieldFlowsFact > SELECT "Account", "Calendar day", "Financial year", "Period", > > [snip] At the very least, include a column list in your INSERT statement. We have no way of checking where any of your r

Re: TSQL To Postgres - Unpivot/Union All

2023-07-20 Thread David G. Johnston
On Thursday, July 20, 2023, Anthony Apollis wrote: > > > I am trying to convert this TSQL: > This doesn’t really seem relevant all that relevant at this point. Given some input data either the query produces the expected result or it doesn’t. > > What am i doing wrong? Please assist? > You n