X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C4C65E46DF for ; Wed, 18 Aug 2004 13:57:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62291-02 for ; Wed, 18 Aug 2004 16:57:36 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 2A4CD5E46DB for ; Wed, 18 Aug 2004 13:57:27 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6112587 for pgsql-sql@postgresql.org; Wed, 18 Aug 2004 09:58:50 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-sql@postgresql.org Subject: Re: SQL Challenge: Arbitrary Cross-tab Date: Wed, 18 Aug 2004 09:56:14 -0700 User-Agent: KMail/1.4.3 References: <200408171955.11850.josh@agliodbs.com> <4122E60F.2080403@joeconway.com> In-Reply-To: <4122E60F.2080403@joeconway.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200408180956.14356.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/205 X-Sequence-Number: 18702 Joe, Elein: > This is pretty much exactly how contrib/tablefunc's crosstab (non-hashed > version; crosstab(sourcesql, ncols)) works. If you really need it to be > portable, though, application layer procedural code is likely to be the > easiest and fastest way to go. crosstab just wraps the procedural code > in an SRF for you. No, you're missing one factor in the spec. Timekeeper_1 for case_id = 182738 is not the same timekeeper as Timekeeper_1 for case_id = 217437. That's why traditional crosstab plans don't work. Anyway, here's the wrap-up: I tried Stephan's idea, it works, but it's so slow that we're going to to the procedural loop. Thanks, all! -- Josh Berkus Aglio Database Solutions San Francisco