insert into pos.dbo.hive_sales
select
    o.Location_Code, o.Order_Date, o.Order_Number, 0, null
from pos.dbo.Orders o
    left join pos.dbo.hive_sales hs
        on hs.Location_Code = o.Location_Code
        and hs.Order_Date = o.Order_Date
        and hs.Order_Number = o.Order_Number
where
    o.Order_Date = ?
    and o.Order_Status_Code = 4
    and hs.Order_Number is null
    and o.Order_Number = ?
