1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

SQL (in Progress Database) - How to Pivot (transpose) a table

Discussão em 'StackOverflow' iniciado por fdantas, Maio 23, 2017.

  1. fdantas

    fdantas Administrator Moderador

    I'm new to SQL, I've been using SQL on a Progress Database (I'm sure it uses SQL92)

    Current Output:

    [​IMG]

    Required Output:

    [​IMG]

    Progress (or at least mine does not support PIVOT)

    I have the following code below:

    Select Account,

    SUM(CASE WHEN AccMonth = '201703' THEN Amount END) AS "201703",
    SUM(CASE WHEN AccMonth = '201702' THEN Amount END) AS "201702",
    SUM(CASE WHEN AccMonth = '201701' THEN Amount END) AS "201701"


    FROM

    (
    Select pub."GL_Table"."AccNum_Col" AS "Account", pub."GL_Table"."AccMnth_Col" AS "AccMonth", Sum(pub."GL_Table"."Amount_Col") AS "Amount"
    FROM pub."GL_Table"
    GROUP BY pub."GL_Table"."AccNum_Col", pub."GL_Table"."AccMnth_Col"
    ) AS tempTB


    GROUP BY Account

    Continue reading...

Compartilhe esta Página