pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedturning a table by 90 degrees
2+ messages / 2 participants
[nested] [flat]
* turning a table by 90 degrees
@ 1999-12-08 08:21 Thilo Mezger <news-list.pgsql.sql@innominate.de>
0 siblings, 1 reply; 2+ messages in thread
From: news-list.pgsql.sql@innominate.de @ 1999-12-08 08:21 UTC (permalink / raw)
To: pgsql-sql
hi,
i've got a table like this (plus a primary key and some other fields):
key | value | custid
---------+---------+---------
name | peter | 2
age | 123 | 2
foo | bar | 2
[...] | |
name | john | 3
[...]
you can think of a table which is turned by 90 degrees. this can be
quite useful when you don't know in advance what key/values pairs you
have to store.
now it would be nice to find a query which returns this result for
custid=2:
name | age | foo
------+-----+------
peter | 123 | bar
any ideas?!
thilo
--
mezger@innominate.de
innominate AG
networking people
fon: +49.30.308806-11 fax: -77 web: http://innominate.de pgp: /pgp/tm
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] turning a table by 90 degrees
@ 1999-12-09 00:18 Peter Eisentraut <peter_e@gmx.net>
parent: Thilo Mezger <news-list.pgsql.sql@innominate.de>
0 siblings, 0 replies; 2+ messages in thread
From: Peter Eisentraut @ 1999-12-09 00:18 UTC (permalink / raw)
To: Thilo Mezger <mezger@innominate.de>; +Cc: pgsql-sql
On 1999-12-08, Thilo Mezger mentioned:
> hi,
>
> i've got a table like this (plus a primary key and some other fields):
>
> key | value | custid
> ---------+---------+---------
> name | peter | 2
> age | 123 | 2
> foo | bar | 2
> [...] | |
> name | john | 3
> [...]
>
> you can think of a table which is turned by 90 degrees. this can be
> quite useful when you don't know in advance what key/values pairs you
> have to store.
>
> now it would be nice to find a query which returns this result for
> custid=2:
>
> name | age | foo
> ------+-----+------
> peter | 123 | bar
I don't see why a table
SELECT * FROM your_table WHERE custid = 2;
would be any different. Just switch the column and row addressing logic in
your application.
key | value | custid
---------+---------+---------
name | peter | 2
age | 123 | 2
foo | bar | 2
There's really no way to do what you suggested.
--
Peter Eisentraut Sernanders väg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-12-09 00:18 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-12-08 08:21 turning a table by 90 degrees Thilo Mezger <news-list.pgsql.sql@innominate.de>
1999-12-09 00:18 ` Peter Eisentraut <peter_e@gmx.net>
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