PIVOT not performing as expected

后端 未结 1 1536
忘掉有多难
忘掉有多难 2021-01-15 04:36

Sorry for an unclear question previously; hopefully I can start again...

I have this data:

entityid    name                 stringvalue
----------- -         


        
相关标签:
1条回答
  • 2021-01-15 05:02

    The answer turned out to be this:

    select *
    from
    (
        select entityid, [name], stringvalue as stringvalue
        from mytable
    ) as d
    pivot
    (
        min(stringvalue)
        for [name] in ([ShortDescription],[LongDescription])
    )
    as p
    

    :)

    The flaw was that the input table should have had 1, 1, 2, 2, 3, 3 for the entityid rows, respectively.

    M

    0 讨论(0)
提交回复
热议问题