Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ydK-0002nI-Qi for pgsql-general@postgresql.org; Tue, 04 Sep 2012 19:17:58 +0000 Received: from vm-emlprdomr-11.its.yale.edu ([130.132.50.177]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T8yd2-0002po-Uw for pgsql-general@postgresql.org; Tue, 04 Sep 2012 19:17:57 +0000 Received: from plattjt.med.yale.edu (plattjt.med.yale.edu [130.132.88.91]) by vm-emlprdomr-11.its.yale.edu (8.14.4/8.14.4) with ESMTP id q84JHbkM030883 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Tue, 4 Sep 2012 15:17:38 -0400 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: crosstab From: Aram Fingal In-Reply-To: <1346784707.8977.6.camel@asus-1001PX.home> Date: Tue, 4 Sep 2012 15:17:36 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <73FF0C6A-965B-4456-BA90-2B8FD1CBC118@multifactorial.com> References: <1346773199616-5722632.post@n5.nabble.com> <1346784707.8977.6.camel@asus-1001PX.home> To: Postgres-General General X-Mailer: Apple Mail (2.1084) X-Scanned-By: MIMEDefang 2.71 on 130.132.50.177 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/95 X-Sequence-Number: 190111 On Sep 4, 2012, at 2:51 PM, Vincent Veyron wrote: > Le mardi 04 septembre 2012 =E0 08:39 -0700, punnoose a =E9crit : >> hi all >> How could i use crostab to display variable number of columns. in the = output=20 >> There could be variable number of columns >=20 > see the documentation for Additional Supplied Modules, in your case > tablefunc : >=20 > http://www.postgresql.org/docs/9.1/static/tablefunc.html I evaluated tablefunc about a year and a half ago and found that it was = not what I wanted because you have to explicitly list what you want the = columns to be. In some cases, there will be hundreds of columns in the = pivoted table. The Reshape library in R can pivot tables without you = even knowing ahead of time how many columns there are going to be. = Maybe I need to revisit the documentation in case I missed something or = if new functionality has been added since I last looked. =20 -Aram=