动态的有点难度,静态的入下: with t as (select 'aa' a, 1 d1, 2 d2 from dual union all select 'bb' a, 1 d1, 2 d2 from dual) select a,d1 from t union all select a,d2 from t order by a,d1;
建议楼主用以下类似的语句 SELECT t.empno,t.ename FROM emp t UNION ALL SELECT t.empno,t.job FROM emp t 有多少列,就写多少。
动态的有点难度,静态的入下: with t as
(select 'aa' a, 1 d1, 2 d2
from dual
union all
select 'bb' a, 1 d1, 2 d2
from dual)
select a,d1 from t
union all
select a,d2 from t order by a,d1;
SELECT t.empno,t.ename FROM emp t
UNION ALL
SELECT t.empno,t.job FROM emp t
有多少列,就写多少。