Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 04A6786080B for ; Tue, 24 Apr 2012 17:01:48 -0300 (ADT) Received: from mailout-de.gmx.net ([213.165.64.23]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SMlvi-0005U1-Vd for pgsql-sql@postgresql.org; Tue, 24 Apr 2012 20:01:47 +0000 Received: (qmail invoked by alias); 24 Apr 2012 20:01:29 -0000 Received: from mue-88-130-57-017.dsl.tropolys.de (EHLO [192.168.1.113]) [88.130.57.17] by mail.gmx.net (mp027) with SMTP; 24 Apr 2012 22:01:29 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX19ZXmYqDC5ZjgbMJ20u/2VEqsIuB70LUSah9GFZS3 SgadOeUGaDb4zB Message-ID: <4F97069B.7020303@gmx.net> Date: Tue, 24 Apr 2012 22:01:31 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: generic crosstab ? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/57 X-Sequence-Number: 36534 Hi, is there a generic solution to dump the result of a query as a crosstab, when I can't know how many columns I will need? E.g. I get something like this: id, x 1, a 1, b 1, c 2, l 2, m and I'd like to see it as: id, x1, x2, x3, ..... xn 1, a, b, c, null, .... null 2, l, m, .... I fear the problem is I dont know n.