pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Torsten Lange <t.lange@ufz.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: pivot-like transformation
Date: Sun, 20 Jun 2004 15:15:39 -0700
Message-ID: <40D60C8B.3060609@joeconway.com> (raw)
In-Reply-To: <1087760651.40d5e90bbd93e@webmail.ufz.de>
References: <1087760651.40d5e90bbd93e@webmail.ufz.de>

Torsten Lange wrote:
> 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       

Not a direct answer with respect to plpgsql, but for pivot table 
functionality see the contrib/tablefunc function crosstab().

> 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?  

Have you looked at the online docs?
http://www.postgresql.org/docs/7.4/static/arrays.html
http://www.postgresql.org/docs/7.4/static/functions-array.html
http://www.postgresql.org/docs/7.4/static/functions-comparisons.html
http://www.postgresql.org/docs/7.4/static/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS

HTH,

Joe



view thread (3+ messages)  latest in thread

Message-ID: <40D60C8B.3060609@joeconway.com>
Permalink:  ../40D60C8B.3060609@joeconway.com/
Also on:    postgresql.org/message-id/40D60C8B.3060609@joeconway.com

 · 

reply

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: mail@joeconway.com, t.lange@ufz.de
  Subject: Re: pivot-like transformation
  In-Reply-To: <40D60C8B.3060609@joeconway.com>

* 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