From: Torsten Lange <t.lange@ufz.de>
To: pgsql-sql@postgresql.org
Subject: pivot-like transformation
Date: Sun, 20 Jun 2004 21:44:11 +0200
Message-ID: <1087760651.40d5e90bbd93e@webmail.ufz.de> (raw)
Hello,
I have a table with measurement values and columns like this:
analyses(id, sample_id, parameter[temperatur...], value, unit[°C...], error)
With PL/PgSQL at the end I want try to perform a pivot-like arrangement of
these data:
sample_id|Temperature [°C]|parameter2 [mg/L]|...|parameterN [L/year]
---------+----------------+-----------------+---+-------------------
5 | 23.00| 0.036|...| 35.1
My first attempts to only give back the original table within a function
failed. There are tons of examples to select one value into a variable...
But for more I browsed through the net and my book but I couldn't find
anything that works. I'm new to PL/PgSQL. Could anyone show me a _very_simple_
example of how to to read (the columns I like) from a table and return the
columns (I like) using tablename%rowtype and an other possiblity if
exists.
I also found very few sources about handling of arrays and how to fill them up
with query results... things like this. Does anyone know a more comprehensive
source?
Thank
you,
Torsten
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: t.lange@ufz.de
Subject: Re: pivot-like transformation
In-Reply-To: <1087760651.40d5e90bbd93e@webmail.ufz.de>
* 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