猿问

java 或者 db2数据库 列传行。将上面的数据转成下面的格式

  •     a标签

    1支行 1

    2支行 0
    3支行 0 
    b标签

    1支行 1

    2支行 0
    3支行 1 
    c标签

    1支行 2

    2支行 0
    3支行 1


        a标签      b标签      c标签

    1支行 1 1 2
    2支行 0 0 0
    3支行 0 1 1


慕斯709654
浏览 747回答 1
1回答

HUWWW

select type,a标签=sum(case when name='a标签' then convert(int,value) else 0 end),b标签=sum(case when name='b标签' then convert(int,value) else null end),c标签=sum(case when name='c标签' then convert(int,value) else null end )from table_1 group by type
随时随地看视频慕课网APP

相关分类

Java
我要回答