Crosstab question

From: "Leendert Paul Diterwich" <paul(at)winaskon(dot)nl>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Crosstab question
Date: 2006-10-21 10:37:08
Message-ID: 4539f855.08cfed7b.4d9c.ffff941f@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear list,

I recently discovered the crosstab function in postgresql.

What I'm trying to accomplish is turn this:

Suppliernumber Productnumber Price

0 2 0.8

0 3 1.2

1 2 0.9

1 3 1.1

Into this:

Productnumber Supplier1 Supplier2

2 0.8 0.9

3 1.2 1.1

The problem is that the data is being shifted when there is no
price for Supplier1 for product 3:

Productnumber Supplier1 Supplier2

2 0.8 0.9

3 1.1(WRONG!)

I'm using this command to retrieve the data:

select * from crosstab('select int_artnr, int_crednr, flt_inkoopprijs from
artcredinkoopprijzen where

int_crednr = 2 OR int_crednr = 3') as c(int_artnr integer, supp1 float4,
supp2

float4);

Am I doing something wrong or is this a limitation of the function?

With kind regards,

Paul

Browse pgsql-hackers by date

  From Date Subject
Next Message Theo Schlossnagle 2006-10-21 13:00:50 Re: xlogdump fixups and WAL log question.
Previous Message Peter Eisentraut 2006-10-21 10:37:02 Re: adminpack and pg_catalog