暂时只想到这个。。 create table tab_a(co_a varchar2,co_b varchar2(2)); select max(decode(co_a,'a','a')), max(decode(co_a,'b','b')), max(decode(co_a,'c','c')) from tab_a where co_a in ('a','b','c') union all select max(decode(co_b,'1','1')), max(decode(co_b,'2','2')), max(decode(co_b,'3','3')) from tab_a where co_a in ('a','b','c')
create table tab_a(co_a varchar2,co_b varchar2(2));
select
max(decode(co_a,'a','a')),
max(decode(co_a,'b','b')),
max(decode(co_a,'c','c'))
from tab_a
where co_a in ('a','b','c')
union all
select
max(decode(co_b,'1','1')),
max(decode(co_b,'2','2')),
max(decode(co_b,'3','3'))
from tab_a
where co_a in ('a','b','c')
如果很多且是变化的,可以写过程来拼接SQL语句。
论坛里很多,自己搜索一下