Re: How can I correctly handle sparse crosstabs?

From: Joe Conway <mail(at)joeconway(dot)com>
To: Rob Richardson <RDRichardson(at)rad-con(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How can I correctly handle sparse crosstabs?
Date: 2014-02-26 16:16:30
Message-ID: 530E135E.5060109@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/26/2014 07:56 AM, Rob Richardson wrote:
> It seems that crosstab queries assume there is going to be a value
> for every possible row in the source query. That?s not what I
> have, and I am not getting the result I need.

<snip>

> There is no relation between the value in the column and the tag
> name the value was associated with in the source table. How can I
> enforce that relationship in a crosstab? Or am I plain out of
> luck?

Please see:
http://www.postgresql.org/docs/9.3/interactive/tablefunc.html

In particular the examples about 2/3rds down the page.

HTH,

Joe

- --
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTDhNeAAoJEDfy90M199hlC5EQAKeooqaU2MeWhJehYwv07Z0T
7vBK781wbrDZaflGCdFauIl+yPxZUjPQUob7+Fzo7CFFtMXC1Sxx762/gp21U2EH
jmkn+PSfbmaSqmL22lr9IKbxsLmXgGNucO3CauwN+f7f09cd8mdptr6TS1R1+kSE
TPMFiJH8nnl1YQ7Z11hNcx/yG6Ad0ihdtyvCX+5DbEIYt6z5TK6tX7KG+YBLTCZN
hRW4WNb3dRYUnR0JFSbCqz9IBRfwL48/PkrzUO/o1i5jHmL19z/36GNJ9ey6rd3e
aqznoa6nUKshisjuv7DuZn1ZpQsZ+tqzJsQEzF8OVdSN/yC0w9740y5ytzcDHBuD
fd5LZfOePhLZqeNfjnFGJeRiWighTmktMO73Jl5EvGzZQFKvPp2+ynk6fp8hLxgW
VtNA7lxLKJEnUWehdgeYrUIX61ukzkBRu27MQrIKV0WgsPk9V6YJ80s09kB5Dvr3
YrrrzNyCi7dP361VO1VF383JXyC4P1ZH5Y2baVXDVKffwVAsBRT3oPhEbEsGzg8m
U2vxQlqQfuLUkaXHibm0F/B/Om7zM1yXi4cKi4W5jv81/6kIe0kz2jGbgI5rEPaB
ylBfzM0vR55xmTDPfmxTnu8tBzrV3Z43aLe7SVQfOeX3EIOTFj2896e0ZnAoyKyb
F2aDdiZBwDO7C2IdhTLJ
=riQs
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sparikh 2014-02-26 16:29:31 xpath functionerror
Previous Message Scott Marlowe 2014-02-26 16:15:01 Cancelling of autovacuums considered harmful