SELECT od.Productcode, od.ProductName, od.ProductNote, od.OrderDetailID, od.OrderID
FROM custopayted.orderdetails od
JOIN products.pins p ON od.productcode = p.productcode
JOIN custopayted.orders o ON o.orderid = od.orderid
WHERE p.Discontinued = 'Y'
AND od.productnote NOT IN  ('FNLA', 'Cancelled', 'LTBO', 'Canceled', 'Cancel Order')
AND o.orderstatus = 'Processing'
AND od.Quantity > 0
AND od.QtyShipped = 0