pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gaetano Mendola <mendola@bigfoot.com>
To: Greg Sabino Mullane <greg@turnstep.com>
Subject: Re: SQL Challenge: Arbitrary Cross-tab
Date: Wed, 18 Aug 2004 13:01:24 +0200
Message-ID: <41233704.9080409@bigfoot.com> (raw)
In-Reply-To: <f02adbf424fb41327573d74965e3555b@biglumber.com>
References: <200408171955.11850.josh@agliodbs.com>
	<f02adbf424fb41327573d74965e3555b@biglumber.com>

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






view thread (16+ messages)  latest in thread

Message-ID: <41233704.9080409@bigfoot.com>
Permalink:  ../41233704.9080409@bigfoot.com/
Also on:    postgresql.org/message-id/41233704.9080409@bigfoot.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mendola@bigfoot.com, greg@turnstep.com
  Subject: Re: SQL Challenge: Arbitrary Cross-tab
  In-Reply-To: <41233704.9080409@bigfoot.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox