SQL - Transpose

后端 未结 3 1060
死守一世寂寞
死守一世寂寞 2021-01-26 23:33

i have small issues i have been trying to figure out in SQL. I have a table with Item Numbers, Attribute Names and Attribute values. Each Item Number might have same or differen

3条回答
  •  醉梦人生
    2021-01-27 00:12

    I have just done this for my own data and I found the following worked for me:

    Change the following line :

        PIVOT 
      (([ATTRIBUTE_VALUE])
      FOR   [ATTR_DISPLAY_NAME] IN ( Select* [ATTR_DISPLAY_NAME] FROM tbl_ICC))
    

    To:

    PIVOT 
      (max(attribute_values) FOR   [ATTR_DISPLAY_NAME] IN ( Select* [ATTR_DISPLAY_NAME] FROM tbl_ICC))
    

    Note I removed the Attribute_Value in the Pivot.

    *note: you need to check your variable names to ensure what I have written is what you need.

提交回复
热议问题