--t你的表col1,col2,col3相同列,col4不同列 select t1.col1,t1.col2,t1.col3,t1.col4,t2.col4 from t t1,t t2 where t1.序号=1 and t2.序号=2
-----假如你的表有6列,id,col1,col2,col3,col4,col5(col4,col5内容不相同)select a.col1 as acol1,a.col2 as acol2,a.col3 as acol3,a.col4 as acol4,a.col5 as acol5,b.col4 as bcol4,b.col5 as bcol5 from t1 a inner join t1 b on b.col1=a.col1 and b.col2=a.col2 and b.col3=a.col3 and a.id<b.id
with test as ( select 1 a ,2 b,3 c ,'test1' d , 1 e from dual union all select 1 ,2,3,'test2',2 from dual ) select * from test pivot ( min(d) for e in (1 d1,2 d2) )
--t你的表col1,col2,col3相同列,col4不同列
select t1.col1,t1.col2,t1.col3,t1.col4,t2.col4
from t t1,t t2
where t1.序号=1 and t2.序号=2
-----假如你的表有6列,id,col1,col2,col3,col4,col5(col4,col5内容不相同)select a.col1 as acol1,a.col2 as acol2,a.col3 as acol3,a.col4 as acol4,a.col5 as acol5,b.col4 as
bcol4,b.col5 as bcol5 from t1 a inner join t1 b on b.col1=a.col1 and b.col2=a.col2 and
b.col3=a.col3 and a.id<b.id
(
select 1 a ,2 b,3 c ,'test1' d , 1 e from dual
union all
select 1 ,2,3,'test2',2 from dual
)
select * from test
pivot
(
min(d)
for e in (1 d1,2 d2)
)