[英]SQL for joining different tables
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.