Given table:
create table test(obj varchar(99), prop varchar(99), val varchar(99));
insert into test (obj , prop , val ) values ('this', 'type A', 'foo');
insert into test (obj , prop , val ) values ('this', 'type B', 'bar');
insert into test (obj , prop , val ) values ('this', 'type C', 'asd');
insert into test (obj , prop , val ) values ('that', 'type B', 'buz');
insert into test (obj , prop , val ) values ('that', 'type A', 'qwe');
How can I select following:
| obj | type A | type B | type C|
this foo bar asd
that qwe buz NULL
This is not a duplicate of "pivot all rows to cols" questions; difference here is condition - value can go to several columns, based on type.