Akansha Akansha - 1 year ago 48
SQL Question

Querying a table for various combinations

I have a table

enter image description here

The above table is the master table. I want to devide them based on caption - like all plan,content and accuracy to group based on parentid.

enter image description here

Need help me with this. Thanks

Answer Source

You can use a PIVOT for this.

    (SELECT ParentID, Caption, Name
        FROM #table) AS t
        FOR Caption IN ([Plan], [Content], [Accuracy])
    ) AS pvt