Thanks for pointing me in the right direction.I found a solution:select coalesce(f.year, y.year), coalesce(f.pid, y.pid), f.amtfrom( ( select * from (select distinct YEAR from finance) as y cross join product ) as y left outer join finance f on y.year = f.year and y.pid = f.pid)
This gives me the required result:2009 3 5.002009 4 45.002010 3 10.002010 4 NULL2011 3 15.002011 4 35.00
Cross joins are something I haven't used before. And the resulting query I found seems to be a bit overcomplicated.Is there perhaps a better way to write it?