Here is the query you are looking for:
DECLARE @Port as TABLE(PortID int,SecID int,Pct float)
DECLARE @Model as TABLE(ModelID int,SecID int,Pct float)
DECLARE @Result as TABLE(PortID int,ModelID int,SecID int,PctPort float,PctModel float);
INSERT INTO @Port(PortID,SecID,Pct)
VALUES (1,1,.25)
,(1,2,.25)
,(1,3,.5)
,(2,1,.5)
,(2,2,.25)
,(2,4,.25)
,(3,4,.25)
,(3,3,.25)
,(3,5,.25)
,(3,6,.25);
INSERT INTO @Model(ModelID,SecID,Pct)
VALUES (1,2,.25)
,(1,3,.25)
,(1,4,.5)
,(2,1,.5)
,(2,2,.25)
,(2,3,.25)
,(3,1,.25)
,(3,4,.25)
,(3,5,.25)
,(3,6,.25);
INSERT INTO @Result(PortID,ModelID,SecID,PctPort,PctModel)
VALUES (1,1,1,0.25,NULL)
,(1,1,2,0.25,0.25)
,(1,1,3,0.5,0.25)
,(1,1,4,NULL,0.5)
,(1,2,1,0.25,0.5)
,(1,2,2,0.25,0.25)
,(1,2,3,0.5,0.25)
,(1,3,1,0.25,0.25)
,(1,3,2,0.25,NULL)
,(1,3,3,0.5,NULL)
,(1,3,4,NULL,0.25)
,(1,3,5,NULL,0.25)
,(1,3,6,NULL,0.25)
,(2,1,1,0.5,NULL)
,(2,1,2,0.25,0.25)
,(2,1,3,NULL,0.25)
,(2,1,4,0.25,0.5)
,(2,2,1,0.5,0.25)
,(2,2,2,0.25,0.25)
,(2,2,3,NULL,0.25)
,(2,2,4,0.25,NULL)
,(2,3,1,0.5,0.25)
,(2,3,2,0.25,NULL)
,(2,3,4,0.25,0.25)
,(2,3,5,NULL,0.25)
,(2,3,6,NULL,0.25)
,(3,1,2,NULL,0.25)
,(3,1,3,0.25,0.25)
,(3,1,4,0.25,0.5)
,(3,1,5,0.25,NULL)
,(3,1,6,0.25,NULL)
,(3,2,1,NULL,0.5)
,(3,2,2,NULL,0.25)
,(3,2,3,0.25,0.25)
,(3,2,4,0.25,NULL)
,(3,2,5,0.25,NULL)
,(3,2,6,0.25,NULL)
,(3,3,1,NULL,0.25)
,(3,3,3,0.25,NULL)
,(3,3,4,0.25,0.25)
,(3,3,5,0.25,0.25)
,(3,3,6,0.25,0.25);
;with ctePort
as (
select distinct PortId from @Port
)
, cteModel
as (
select distinct ModelId from @Model
)
, cteSec
as (
select SecId from @Port
union
select SecId from @Model
)
,myFinal as (
select m1.PortId,m2.ModelId,m3.SecId
from ctePort m1,cteModel m2,cteSec m3
)
select
f.PortID,f.ModelID,f.SecID
,p.pct PctPort,m.pct as PctModel
from myFinal f
left join @Port p on f.PortId=p.PortId and f.SecId=p.SecId
Left join @Model m on f.ModelId=m.ModelId and f.SecId=m.SecId
where Not(p.pct is null and m.pct is null)
Order by f.PortID,f.ModelID,f.SecID
SELECT * FROM @Result