Split column into multiple based on value RRS feed

  • Question

  • I am looking to split a column into 4 parts based on the value in the column

    eg. table:

    ID | Some No

    a          1    3

    b          2    4

    c          3    2

    d          4    1

    what I am looking for

    ID | new col | new col | new col | new col 

    a          1                         3

    b                       2                           4

    c                       2            3           

    d          1                                        4

    I am unsure hoe to code this using SQL, any help would be great

    Monday, October 14, 2019 8:01 AM

All replies

  • It would definitely help if you could describe the actual business problem, because the request is quite odd from a relational perspective. Not the least the desired result.

    It would also help if you can post CREATE TABLE statements for  your table and INSERT statements with sample data, so we understand it better. The source format also seems to be non-relational.

    Erland Sommarskog, SQL Server MVP,

    Monday, October 14, 2019 9:41 PM