Search Postgresql Archives

Re: big un stacking query - help save me from myself

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kirk Wythers <wythe001@xxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux