【发布时间】:2016-10-03 16:40:31
【问题描述】:
【问题讨论】:
-
第二个表和你的问题有什么关系?你需要某种支点,没有连接也没有联合。解决方案取决于您的 Oracle 版本,您应该始终将其包含在您的问题中。
-
请将数据粘贴为文本,这有助于测试,也有助于图像被屏蔽的人
-
我尝试使用 pivot 但我是新手,所以我没有得到我想要的输出
【问题讨论】:
select
'group_a' as groupname
, max( case classname when 'C123' then group_a else null end) as c123
, max( case classname when 'C456' then group_a else null end) as c456
from table1
union all
select
'group_b' as groupname
, max( case classname when 'C123' then group_b else null end) as c123
, max( case classname when 'C456' then group_b else null end) as c456
from table1
union all
select
'group_d' as groupname
, max( case classname when 'C123' then group_d else null end) as c123
, max( case classname when 'C456' then group_d else null end) as c456
from table1
union all
select
'group_e' as groupname
, max( case classname when 'C123' then group_e else null end) as c123
, max( case classname when 'C456' then group_e else null end) as c456
from table1
【讨论】: