Re: full join question...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jonas(dot)f(dot)henriksen(at)imr(dot)no
Cc: Niklas Johansson <spot(at)tele2(dot)se>, pgsql-general(at)postgresql(dot)org
Subject: Re: full join question...
Date: 2006-04-05 19:09:14
Message-ID: 12591.1144264154@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Jonas F. Henriksen" <jonas(dot)f(dot)henriksen(at)imr(dot)no> writes:
> Well, the problem is I want the result on one row for each depth, so it
> will fit nicely into a table, like this:

> depth measuretype1_value measuretype2_value
> 10 1.78 2.55
> 20 2.12
> 30 3.12
> 40 1.3 1.4

I think what you have to do is filter the rows according to measuretype
*before* you join them. Something like

select * from
(select depth, value as measuretype1_value from testtable
where measuretype = 1040) ss1
full join
(select depth, value as measuretype2_value from testtable
where measuretype = 4001) ss2
using (depth);

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-04-05 19:14:32 Re: Creating an index on PostgreSQL 7.4.3
Previous Message Ardian Xharra (Boxxo) 2006-04-05 19:07:43 Re: Creating an index on PostgreSQL 7.4.3