Skip site navigation (1) Skip section navigation (2)

Re: SQL Challenge: Arbitrary Cross-tab

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: josh(at)agliodbs(dot)com
Subject: Re: SQL Challenge: Arbitrary Cross-tab
Date: 2004-08-18 03:36:41
Message-ID: f02adbf424fb41327573d74965e3555b@biglumber.com (view raw or flat)
Thread:
Lists: pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
 
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;
 
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200408172335
-----BEGIN PGP SIGNATURE-----
 
iD8DBQFBIs7AvJuQZxSWSsgRAkglAJ9mNEmOYlLPynygMmelvzlqkYoHlwCeJqTb
g5gyh9LztONPCZj32aOEuGI=
=Yy7m
-----END PGP SIGNATURE-----



In response to

Responses

pgsql-sql by date

Next:From: Josh BerkusDate: 2004-08-18 03:41:09
Subject: Re: SQL Challenge: Arbitrary Cross-tab
Previous:From: Stephan SzaboDate: 2004-08-18 03:35:53
Subject: Re: SQL Challenge: Arbitrary Cross-tab

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group