SQL Server: Examples of PIVOTing String data

前端 未结 7 1263
忘掉有多难
忘掉有多难 2020-11-21 13:20

Trying to find some simple SQL Server PIVOT examples. Most of the examples that I have found involve counting or summing up numbers. I just want to pivot some string data.

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-21 13:40

    With pivot_data as
    (
    select 
    action, -- grouping column
    view_edit -- spreading column
    from tbl
    )
    select action, [view], [edit]
    from   pivot_data
    pivot  ( max(view_edit) for view_edit in ([view], [edit]) ) as p;
    

提交回复
热议问题