From: | John Fabiani <johnf(at)jfcomputer(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | crosstab help |
Date: | 2012-02-24 08:11:28 |
Message-ID: | 2071893.Jsp6YpFfLm@linux-12 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I have a simple table
item_number week_of planned_qoh
------------------ ------------------ ------------------
00005 2012-02-05 30
00005 2012-02-12 40
00005 2012-02-19 50
where
item_number text
week_of date
planned_qoh integer
I have a function that returns the table as above:
chromasun._chromasun_totals(now()::date)
I want to see
00005 2012-02-05 2012-02-12 2012-02-19
30 40 50
This is what I have tried (although, I have tired many others)
select * from crosstab('select item_number::text as row_name,
to_char(week_of,''MM-DD-YY'') as bucket, planned_qoh::integer as buckvalue
from xchromasun._chromasun_totals(now()::date)')
as ct(item_number text, week_of date, planned_qoh integer)
I get
ERROR: return and sql tuple descriptions are incompatible
What am I doing wrong?
Johnf
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Gaab | 2012-02-24 08:27:38 | Re: crosstab help |
Previous Message | Jasen Betts | 2012-02-23 09:14:32 | Re: How to split up phone numbers? |