Sql 在oracle中将行输出转换为列

Sql 在oracle中将行输出转换为列,sql,oracle,oracle11g,oracle10g,Sql,Oracle,Oracle11g,Oracle10g,我希望输出为一列三行。 有关更多详细信息,请参见图片。使用union all: select count_emp from cte1 union all select count_dept from cte2 union all select count_hr from cte3; 请注意,结果不保证按任何特定顺序排列。我强烈建议您标记行: select 'emp', count_emp as cnt from cte1 union all select 'dept', count_dept

我希望输出为一列三行。
有关更多详细信息,请参见图片。

使用
union all

select count_emp from cte1
union all
select count_dept from cte2
union all
select count_hr from cte3;
请注意,结果不保证按任何特定顺序排列。我强烈建议您标记行:

select 'emp', count_emp as cnt from cte1
union all
select 'dept', count_dept from cte2
union all
select 'hr', count_hr from cte3;
select 'emp', count_emp as cnt from cte1
union all
select 'dept', count_dept from cte2
union all
select 'hr', count_hr from cte3;