pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Leendert Paul Diterwich <paul@winaskon.nl>
To: pgsql-sql@postgresql.org
Subject: Crosstab question
Date: Sun, 22 Oct 2006 13:57:09 +0200
Message-ID: <453b5c95.3a026987.2aae.ffffb959@mx.google.com> (raw)

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                  

                        

view thread (4+ messages)  latest in thread

Message-ID: <453b5c95.3a026987.2aae.ffffb959@mx.google.com>
Permalink:  ../453b5c95.3a026987.2aae.ffffb959@mx.google.com/
Also on:    postgresql.org/message-id/453b5c95.3a026987.2aae.ffffb959@mx.google.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: paul@winaskon.nl
  Subject: Re: Crosstab question
  In-Reply-To: <453b5c95.3a026987.2aae.ffffb959@mx.google.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