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 8E2465E46DB for ; Wed, 18 Aug 2004 08:12:46 -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 20998-01 for ; Wed, 18 Aug 2004 11:12:39 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id C30785E46D7 for ; Wed, 18 Aug 2004 08:12:38 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i7IBCZiI021373 for ; Wed, 18 Aug 2004 11:12:36 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i7IB1PkC018025 for pgsql-sql@postgresql.org; Wed, 18 Aug 2004 11:01:25 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.sql Subject: Re: SQL Challenge: Arbitrary Cross-tab Date: Wed, 18 Aug 2004 13:01:24 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 25 Message-ID: <41233704.9080409@bigfoot.com> References: <200408171955.11850.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: Greg Sabino Mullane User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200408/187 X-Sequence-Number: 18684 Greg Sabino Mullane wrote: > > Names shortened to spare the line lengths: > > SELECT bob.cid, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1) AS tk1, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 1) AS tk2, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 2) AS tk3, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 3) AS tk4, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 4) AS tk5, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 5) AS tk6, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 6) AS tk7, > (SELECT tid FROM ats WHERE cid=bob.cid LIMIT 1 OFFSET 7) AS tk8, > FROM (SELECT DISTINCT cid FROM ats) AS bob; > Don't you miss for each subselect an order by tid ? Regards Gaetano Mendola