For defined group of possible pairs you can build query like below.
select productid pid,
sum (case when marketid='M1' and currencyid='C1' then price else null end) m1c1,
sum (case when marketid='M1' and currencyid='C2' then price else null end) m1c2,
sum (case when marketid='M2' and currencyid='C1' then price else null end) m2c1,
sum (case when marketid='M2' and currencyid='C2' then price else null end) m2c2,
sum (case when marketid='M3' and currencyid='C3' then price else null end) m3c3
from products
group by productid
Results:
PID M1C1 M1C2 M2C1 M2C2 M3C3
---------- ---------- ---------- ---------- ---------- ----------
P1 100 200 300 400
P2 500
P3 600
To make this dynamically you can create PLSQL procedure, I think.
Edit: "Dynamic" solution with procedure building view v_products
:
begin p_products; end;
select * from v_products;
Output:
PID M1_C1 M1_C2 M2_C1 M2_C2 M3_C3
---------- ---------- ---------- ---------- ---------- ----------
P1 100 200 300 400
P2 500
P3 600
Procedure p_products code:
create or replace procedure p_products is
v_sql varchar2(4000) :=
'create or replace view v_products as select productid pid, ';
begin
for o in (
select distinct marketid mid, currencyid cid from products
order by marketid, currencyid)
loop
v_sql := v_sql||' sum (case when marketid='''||o.mid
||''' and currencyid='''||o.cid||''' then price else null end) '
||o.mid||'_'||o.cid||', ';
end loop;
v_sql := rtrim(v_sql, ', ');
v_sql := v_sql||' from products group by productid';
execute immediate v_sql;
end;