在Oracle中将多行多列转换为单行多列

时间:2018-12-06 18:01:59

标签: oracle

我有类似

的数据
name    | type1 | type2
======================    
abc     |  YES  | 
abc     |       |  Yes 

我希望这些数据像

name| type1 | type2
==================
abc  | YES  |YES 

请帮助我进行查询。

1 个答案:

答案 0 :(得分:0)

一些聚合

SQL> with test (name, type1, type2) as
  2    (select 'abc', 'YES', null  from dual union all
  3     select 'abc', null , 'Yes' from dual
  4    )
  5  select name, max(type1) type1, max(type2) type2
  6  from test
  7  group by name;

NAM TYP TYP
--- --- ---
abc YES Yes

SQL>
相关问题