Pivot One Row Field for All Rows Containing Same Time

  • I thought this was simple and it probably is but I have searched for 3 days with no solution. I think part of my problem is I don't know how to word it for the search engine. Here is a sample of what I would like my result to be based on the data from the first 5 rows to give me the sixth row which is the pivot of the Type column and B field Value only.

    IdentifierTimeTypeValue Etc Type_B

    D1 1/1/2015 0:00A310"1"

    D11/1/2015 0:00B"1"20"1"

    D11/1/2015 0:00C230"1"...

    D11/1/2015 1:00A3100

    D11/1/2015 1:00B0200

    D11/1/2015 1:00C2300

    D11/1/2015 2:00A3101

    D11/1/2015 2:00B1201

    D11/1/2015 2:00C2301

    D21/1/2015 0:00A310"0"

    D21/1/2015 0:00B"0"20"0"

    D21/1/2015 0:00C230"0"...

    D21/1/2015 1:00A3101

    D21/1/2015 1:00B1201

    D21/1/2015 1:00C2301

    D21/1/2015 2:00A3100

    D21/1/2015 2:00B0200

    D21/1/2015 2:00C2300

    Any help would be greatly appreciated.

    Thanks,

    Rich:hehe:

  • Your question is not clear to me. Please provide sample data, DDL and desired results in a consumable form, as described in the first link in my signature.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • All data you would need is there. I don't have any DDL's as this is a sample. The original table if I had one would be the first 5 columns of the data above.

    To ask a question then here goes, for each row containing the same identifier and date/hour I need the "VALUE" of the column "TYPE" where "TYPE" = "B" placed in the column "TYPE_B" for each row.

    As for the results it would look like what is shown above. The "ETC" column just denotes that I have other columns that need to be displayed in the results.

    Thanks,

    Rich

  • o324712 (11/22/2015)


    All data you would need is there. I don't have any DDL's as this is a sample. The original table if I had one would be the first 5 columns of the data above.

    To ask a question then here goes, for each row containing the same identifier and date/hour I need the "VALUE" of the column "TYPE" where "TYPE" = "B" placed in the column "TYPE_B" for each row.

    As for the results it would look like what is shown above. The "ETC" column just denotes that I have other columns that need to be displayed in the results.

    Thanks,

    Rich

    Rich, if you want a little coded help on this, please read the article at the first link in my signature line below for how to provide some readily consumable data.

    If you don't want coded help, then lookup "Converting Rows to Columns" in Google.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Okay, thanks for the suggestions.

    Rich

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply