Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT7G5-0008Jl-Aa for pgsql-sql@arkaria.postgresql.org; Wed, 13 Jun 2018 15:00:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fT7G4-00062g-0D for pgsql-sql@arkaria.postgresql.org; Wed, 13 Jun 2018 15:00:24 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT7G3-00062M-Pv for pgsql-sql@lists.postgresql.org; Wed, 13 Jun 2018 15:00:23 +0000 Received: from mail.fmed.uba.ar ([157.92.152.1] helo=azteca.fmed.uba.ar) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT7Fw-0000hE-CD for pgsql-sql@lists.postgresql.org; Wed, 13 Jun 2018 15:00:23 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id 326891F6112F; Wed, 13 Jun 2018 12:00:09 -0300 (-03) Received: from azteca.fmed.uba.ar ([127.0.0.1]) by localhost (azteca.fmed.uba.ar [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id E0Gq_oXv24Vt; Wed, 13 Jun 2018 12:00:08 -0300 (-03) Received: from localhost (localhost.localdomain [127.0.0.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id 852971F61171; Wed, 13 Jun 2018 12:00:08 -0300 (-03) X-Virus-Scanned: amavisd-new at fmed.uba.ar Received: from azteca.fmed.uba.ar ([127.0.0.1]) by localhost (azteca.fmed.uba.ar [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GFfnNwm1O63J; Wed, 13 Jun 2018 12:00:08 -0300 (-03) Received: from azteca.fmed.uba.ar (azteca.fmed.uba.ar [157.92.152.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id D7D731F61034; Wed, 13 Jun 2018 11:51:11 -0300 (-03) Date: Wed, 13 Jun 2018 14:51:11 +0000 (UTC) From: Gerardo Herzig To: Olivier =?utf-8?Q?Lepr=C3=AAtre?= Cc: pgsql-sql@lists.postgresql.org Message-ID: <1734068522.267007.1528901471548.JavaMail.zimbra@fmed.uba.ar> In-Reply-To: <1665819120.267000.1528901466329.JavaMail.zimbra@fmed.uba.ar> References: <5b212b57.1c69fb81.2e3b4.1d26@mx.google.com> Subject: Re: Window ? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [157.92.152.1] X-Mailer: Zimbra 8.5.1_GA_3056 (ZimbraWebClient - FF52 (Linux)/8.5.1_GA_3056) Thread-Topic: Window ? Thread-Index: AdQDI4sgmcOtDRUhT1WuzXuaXOngsedvB8D9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ----- Mensaje original ----- > De: "Olivier Lepr=C3=AAtre" > Para: pgsql-sql@lists.postgresql.org > Enviados: Mi=C3=A9rcoles, 13 de Junio 2018 11:33:50 > Asunto: Window ? > Hi, >=20 >=20 >=20 > I have a road segment table with a few attributes for each. For each > segment, I have a road index and a segment index something like : >=20 >=20 >=20 > road seg colA >=20 > 1 1 att1 >=20 > 1 2 att2 >=20 > 1 3 att3 >=20 > 1 4 att4 >=20 > 2 1 att5 >=20 > 2 2 att6 >=20 >=20 >=20 > I want to convert records into lines, >=20 >=20 >=20 > 1 att1 att2 att3 att4 >=20 > 2 att5 att6 ... >=20 >=20 Looks like a solution with "pivot": https://www.postgresql.org/docs/current/static/tablefunc.html Look for "crosstab" functions. HTH Gerardo