Need help to convert multiple rows of 0,1 to single row

  • Hi,

    I need help in building following logic:

    Existing dataset:

    Col1 Col2 Col3 Col4 Col5 Col6

    A 1 0 0 0 0

    A 0 1 0 0 0

    A 0 0 1 0 1

    A 0 0 0 1 0

    A 0 0 0 0 1

    B 0 1 0 0 0

    B 1 0 0 0 0

    Needed dataset:

    Col1 Col2 Col3 Col4 Col5 Col6

    A 1 1 1 1 1

    B 1 1 0 0 0

    I need to convert multiple records to to a single row per value of A, B,.....

    Any thoughts will be helpful!!!

    Thanks

  • looks like a simple grouping problem..is this homework?

    SELECT

    Col1,

    MAX(Col2),

    MAX(Col3),

    MAX(Col4),

    MAX(Col5),

    MAX(Col6)

    GROUP BY Col1

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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