ProductID 11 is currently out of stock.
It has a quntity of 0
I need to get the orders that have productid = 11
and only other products that are in stock.
Here is what I'm using, but it is returning products that have a quantity of 0.
from Orders a
inner join LineItems b
on a.OrderID = b.OrderID
and b.ProductID = 11
where a.OrderStatusID = 3
and a.GatewaySuccessful = 1 and not exists
from Products p
where b.ProductID = p.ProductID
and p.QuantityInStock > 0)