Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iUw19-0005gJ-HE for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2019 17:01:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iUw0A-0004uO-AU for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2019 17:00:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iUw0A-0004uH-0c for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2019 17:00:18 +0000 Received: from evolu-s.it ([94.23.66.144] helo=smtp.evolu-s.it) by magus.postgresql.org with smtp (Exim 4.89) (envelope-from ) id 1iUw04-0007fo-3F for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2019 17:00:17 +0000 Received: from [192.168.1.129] ([79.6.30.247]) by smtp.evolu-s.it ; Wed, 13 Nov 2019 18:00:07 +0100 Subject: Re: CASE(?) to write in a different column based on a string pattern To: pgsql-general@lists.postgresql.org References: <5bbe8366-bcd4-7f6f-94c8-ebc465c3b6b7@evolu-s.it> From: Moreno Andreo Message-ID: <148477df-180e-3a9a-97f8-c27de5c2f2c1@evolu-s.it> Date: Wed, 13 Nov 2019 18:00:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: it List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Il 13/11/19 17:48, Andrew Kerber ha scritto: > So what you are doing is transforming the table format from vertical > to horizontal.  I think you will want to use a union to join the table > to itself along with the case statement to produce the output you are > looking for. > Not precisely, the string pattern is only part of a bigger table (30 columns in total), what I'm trying to achieve is what Geoff explained, just split values in 3 different columns based on the string pattern Thanks for your time Moreno.