Re: SQL Challenge: Arbitrary Cross-tab

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Subject: Re: SQL Challenge: Arbitrary Cross-tab
Date: 2004-08-18 11:01:24
Message-ID: 41233704.9080409@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Sabino Mullane 2004-08-18 11:47:41 Re: SQL Challenge: Arbitrary Cross-tab
Previous Message Theo Galanakis 2004-08-18 06:11:55