From: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
---|---|
To: | Kirk Wythers <wythe001(at)umn(dot)edu> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: big un stacking query - help save me from myself |
Date: | 2013-03-15 20:09:31 |
Message-ID: | 1363378171.8307.YahooMailNeo@web162902.mail.bf1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Kirk Wythers <wythe001(at)umn(dot)edu> wrote:
> Here is a simplified version of the query approach I am
> attempting.
> CREATE TABLE unstacked_table AS (
> SELECT
> var1,
> var2,
> var3,
> MAX (
> CASE
> WHEN variable_name = 'unstack1' THEN
>
> VALUE
>
> END
> ) AS unstack1,
> MAX (
> CASE
> WHEN variable_name = 'unstack2' THEN
>
> VALUE
>
> END
> ) AS unstack2,
> MAX (
> CASE
> WHEN variable_name = 'unstack3' THEN
>
> VALUE
>
> END
> ) AS unstack3,
> MAX (
> CASE
> WHEN variable_name = 'unstack4' THEN
>
> VALUE
>
> END
> ) AS unstack4
> FROM
> stacked_table
> GROUP BY
> variable1,
> variable2,
> variable3
> )
> ;
This is still not making sense to me. Is VALUE intended to be a
place-holder showing where you have a literal in the code? If so,
what is the point of using MAX? Could you create a sample
"stacked" table, insert about 10 rows, and show the SELECT which
would give the "unstacked" form?
--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Crawford | 2013-03-15 21:21:17 | Re: Addled index |
Previous Message | Oleg Alexeev | 2013-03-15 18:29:53 | Addled index |