• gregorykearney (9/3/2013)


    table gennum

    tollnum, n1, n2, n3

    800123, 1234, 1235, 1236

    999123, 9876, 9875, 9874

    I want to my data to look like:

    tollnum,code

    800123, 1234

    800123, 1235

    800123, 1236

    999123, 9876

    999123, 9875

    999123, 9874

    How do I convert column data into row data?

    Hi,

    You can use the UNPIVOT statment:

    SELECT tollnum,

    code

    FROM (SELECT *

    FROM gennum) p

    UNPIVOT

    (code

    FOR n IN ( n1, n2, n3 ) ) AS unpvt

    ORDER BY tollnum, n



    If you need to work better, try working less...