那么,现在如果给出一个权限编号,要去检索出用后这个权限的用户集合,就会需要在逗号分隔的多个权限编号中去匹配给出的这个权限编号。如果使用like去做,一则效率不高,二则匹配不精确。因此用到了逗号分隔列转行的方法。目前该方法只适合在oracle数据库中使用。该方法只需要sql语句就可以实现列转行。
下面给出该方法的示例:
select a,b,c from(with test as (select ‘aaa’ a,’bbb’ b,’1,2,3′ c from dual)select a,b,su
行转列
一张表
查询结果为
–行转列
select years,(select amount from Tb_Amount as A where month=1 and A.years=Tb_Amount.years)as m1,
(select amount from Tb_Amount as A where month=2 and A.years=Tb_Amount.years)as m2,
(select amount from Tb_Amount as A where mon