Pivot a row

  • Hi,

    I have a set of rows that need to be pivoted. Pls find the table strucutre below.

    RowID Int Auto Identity

    Col1 Int Primary Key

    Col2 Int Primary Key

    Col3 Int Primary Key

    Col4 Int Primary Key

    Col5 Int Primary Key

    ErrorCD varchar(10)

    In the above table each composite Pkey will be having more than one error code. When we query this table this looks like as below...

    RowID

  • You hit the "Submit" button before u completed the question, right? i dont find the requirement there :w00t:

  • We definitely need more information. If that is all the information, though, then FYI: Pivot does not work if you don't have something to aggregate on.

    You need to SUM() or COUNT() or something (usually SUM()) in order to be able to use the actual PIVOT command. If you don't have that, then you'll need to come up with some sort of RBAR loop or cursor to force it.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • DUPLICATE POST! Please direct all responses here: http://www.sqlservercentral.com/Forums/Topic1126304-149-1.aspx

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

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

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