There are some extra records that need to be included where an ID is null.
The where clause has all the id's but ignoring the null values.
Here is a couple attempts:
--@Stages dbo.int_tbltype READONLY SELECT ISNULL(s.StageID, 0) AS StageID, o.OrderID FROM Order o LEFT JOIN Stage s ON s.StageID = o.StageID AND ISNULL(s.StageID, 0) = o.StageID where s.StageID IN (0, 1, 11, 3, 13, 2, 4, 5, 6, 12, 7, 14) --s.StageID IN (SELECT ID FROM @Stages)
Please note that the where clause will actually contain a table type.
I tried to return the null id's from the select and from the join.