Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMV11-002Xew-9j for pgsql-general@arkaria.postgresql.org; Thu, 20 Jul 2023 14:52:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qMV0z-009gQz-Pq for pgsql-general@arkaria.postgresql.org; Thu, 20 Jul 2023 14:52:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMV0U-009aJ6-G2 for pgsql-general@lists.postgresql.org; Thu, 20 Jul 2023 14:51:54 +0000 Received: from mail-ej1-f41.google.com ([209.85.218.41]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qMV0Q-000fQ6-BQ for pgsql-general@lists.postgresql.org; Thu, 20 Jul 2023 14:51:53 +0000 Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-992ace062f3so151137166b.2 for ; Thu, 20 Jul 2023 07:51:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689864710; x=1690469510; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xzgdLloyvxuvMHvaX1+xe3ouyWtJUzefJEqdln8Xwx4=; b=KXPy2vP3Hk2iJdmcvoKYFUBESsi4R9zafmAgtFwjvWLqK+F+jpTvWRU44F2aCgmIw3 +VfC8JL++CdFdsuRhETZRwjWqkvwjCDcbEp9sg+WdWVIHBn55ZzVp1M1uIkw9Kh8BtIU mAe/0kJRItKudmAGa1xJTLSbPl32okK/P3bDXKBSpVH8p0yQhn7kaldXCqWZDVHt85cU J5Rp0hsMH1H+S5Ni8ZtbWQ5hqg5zPg/s3JX4sgEh3zJs2oT9p+8XUaGTv9uYQBU7b+g6 3VAx9ab4CHaNag8SePxltzewXW8ficMCbsz1N0BxMFFb7WW2sHUzFKOPS8yVjlvxr4X5 2Gng== X-Gm-Message-State: ABy/qLaFkdo9Ic1ciFsxYJv5fOre2sfmXmN2SYkRTMR3qjLhzKbMnvGe 2UIFMs/ltAjpuYF1NmHevbIVLN4d6f1hqgpfDHGS54dKEA== X-Google-Smtp-Source: APBJJlErQg0+fjAh+xIVkDxN/mkcZjOi5vLw+Ss6ZAiRjS0fHzx4KyIWbO2cSSKc/QA9WsLeS/8DJuXa351C2AT8tNk= X-Received: by 2002:a17:907:320b:b0:997:beca:f9db with SMTP id xg11-20020a170907320b00b00997becaf9dbmr3157675ejb.54.1689864709531; Thu, 20 Jul 2023 07:51:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Geoff Winkless Date: Thu, 20 Jul 2023 15:51:35 +0100 Message-ID: Subject: Re: TSQL To Postgres - Unpivot/Union All To: Anthony Apollis Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 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