case肯定搞不定拉,不用函数可以吗?

解决方案 »

  1.   

    假设楼主最上面表的两列名称分别为name和id,表名为table,试试这个:
    select id,max(clum2),max(clum3),max(clum4),max(clum5),max(clum6),max(clum7) from 
    (
    select id,
    (case when name='管理' then name else null end) as clum2,
    (case when name='经济' then name else null end) as clum3,
    (case when name='研发' then name else null end) as clum4,
    (case when name='爱情' then name else null end) as clum5,
    (case when name='生活' then name else null end) as clum6,
    (case when name='朋友1' then name else null end) as clum7
    from table
    ) group by id