Hej Magnus!
Så här kan man göra:
select a.land, a.typ, a.antal as funktion, b.antal as sales
from crosstabTest a, crosstabTest b
where a.land = b.land
and a.typ = b.typ
and a.funktion = 'operating'
and b.funktion = 'sales'
union
select a.land, a.typ, a.antal as funktion, 0
from crosstabTest a
where a.funktion = 'operating'
and not exists
(select * from crosstabTest b
where a.land = b.land
and a.typ = b.typ
and b.funktion = 'sales')
union
select a.land, a.typ, 0, a.antal as sales
from crosstabTest a
where a.funktion = 'sales'
and not exists
(select * from crosstabTest b
where a.land = b.land
and a.typ = b.typ
and b.funktion = 'operating')
Först tyckte jag man borde kunna göra det snitsigare med en inner join, men jag lyckas inte... Det här funkar i alla fall!