行列转换问题 select max(decode(字段名1,'种类1',字段名2))种类1, max(decode(字段名1,'种类2',字段名2))种类1 from tt group by trunc((rownum-1)/2)
我来一个,不过性能就不知道好不好了select a.字段名2, b.字段名2 from (select 字段名2, rownum rn from tt where 字段名1='种类1') a full join (select 字段名2, rownum rn from tt where 字段名1='种类2') b on a.id=b.id
把id改为rnselect a.字段名2, b.字段名2 from (select 字段名2, rownum rn from tt where 字段名1='种类1') a full join (select 字段名2, rownum rn from tt where 字段名1='种类2') b on a.rn=b.rn
select max(decode(字段名1,'种类1',字段名2))种类1,
max(decode(字段名1,'种类2',字段名2))种类1
from tt
group by trunc((rownum-1)/2)
不固定的话,就要动态列了,拼sql来写了,单条sql不能做动态列的。只要列能够固定下来才能用sql来做。