select 'Answer' type, max(case when date='2011' then answer end) as '2011', max(case when date='2012' then answer end) as '2012', max(case when date='2013' then answer end) as '2013', max(case when date='2014' then answer end) as '2014', max(case when date='2015' then answer end) as '2015', max(case when date='2016' then answer end) as '2016', max(case when date='2017' then answer end) as '2017' from ( select '2011' date , 'y' answer , 'y' qui union all select '2012' date , 'y' answer , 'n' qui union all select '2013' date , 'n' answer , 'n' qui union all select '2014' date , 'y' answer , 'y' qui union all select '2015' date , 'y' answer , 'y' qui union all select '2016' date , 'n' answer , 'n' qui union all select '2017' date , 'n' answer , 'y' qui ) a union all select 'Qui' type, max(case when date='2011' then qui end), max(case when date='2012' then qui end), max(case when date='2013' then qui end), max(case when date='2014' then qui end), max(case when date='2015' then qui end), max(case when date='2016' then qui end), max(case when date='2017' then qui end) from ( select '2011' date , 'y' answer , 'y' qui union all select '2012' date , 'y' answer , 'n' qui union all select '2013' date , 'n' answer , 'n' qui union all select '2014' date , 'y' answer , 'y' qui union all select '2015' date , 'y' answer , 'y' qui union all select '2016' date , 'n' answer , 'n' qui union all select '2017' date , 'n' answer , 'y' qui ) a ; select b.type, max(case when date='2011' and type = 'Answer' then answer when date='2011' and type = 'Qui' then qui end) as '2011', max(case when date='2012' and type = 'Answer' then answer when date='2012' and type = 'Qui' then qui end) as '2012', max(case when date='2013' and type = 'Answer' then answer when date='2013' and type = 'Qui' then qui end) as '2013', max(case when date='2014' and type = 'Answer' then answer when date='2014' and type = 'Qui' then qui end) as '2014', max(case when date='2015' and type = 'Answer' then answer when date='2015' and type = 'Qui' then qui end) as '2015', max(case when date='2016' and type = 'Answer' then answer when date='2016' and type = 'Qui' then qui end) as '2016', max(case when date='2017' and type = 'Answer' then answer when date='2017' and type = 'Qui' then qui end) as '2017' from ( select '2011' date , 'y' answer , 'y' qui union all select '2012' date , 'y' answer , 'n' qui union all select '2013' date , 'n' answer , 'n' qui union all select '2014' date , 'y' answer , 'y' qui union all select '2015' date , 'y' answer , 'y' qui union all select '2016' date , 'n' answer , 'n' qui union all select '2017' date , 'n' answer , 'y' qui ) a cross join (select 'Answer' type union all select 'Qui') b group by b.type;
전 이렇게 무식하게밖에... ㅠㅠ