Merging two rows into one by creating two new columns based on criteria from same table (SQL) the data that I have looks like this

name      year      quarter      type        score 
a         2016         Q1         x           40    
a         2016         Q1         y           50


I want to write a statement that will merge these two rows into one column output based on the name year and quarter regardless of type by creating two new columns, or one new column. The output that I would like is:

name      year      quarter      type        score      x_score      y_score
a         2016        Q1          x           40          40           50


I tried writing some subqueries, but could not understand how to effectively do this.

Thanks in advance
Here is one way:

SELECT name, year, quarter, type, coalesce(x_score, y_score) score, x_score, y_score 
FROM (
   select name, year, quarter, min(type) type
      , min(case when type='x' then score else null end) x_score
      , min(case when type='y' then score else null end) y_score
   from t1
   group by name, year, quarter
);


Using this setup data:

drop table t1;
create table t1 (name varchar2(1), year number(4), quarter Varchar2(2), type varchar2(1)
   , score number(3));
insert into t1 (name, year, quarter, type, score) values ('a',2016,'Q1','x',40);
insert into t1 (name, year, quarter, type, score) values ('a',2016,'Q1','y',50);
insert into t1 (name, year, quarter, type, score) values ('b',2016,'Q1','x',40);
insert into t1 (name, year, quarter, type, score) values ('a',2017,'Q1','x',40);
commit;
select * from t1;