New feature! Upgrade and increase expert visibility of your issues with Priority Questions.
==================================== ==THE RESULTSET ==================================== PRODUCT_ID QtyInStock QtyOrdered 1032 1 1 1016 10 1 1018 0 1 ========================== ===THE QUERY ========================== SELECT Product.PRODUCT_ID, IsNull(Count(Stock.STOCK_ID),0) As QtyInStock, (SELECT TRANS_CLIENT_STOCK.QTY FROM TRANS_CLIENT_STOCK WHERE TRANS_CLIENT_STOCK.TC_ID = 94403 AND TRANS_CLIENT_STOCK.PRODUCT_ID = Product.PRODUCT_ID) AS QtyOrdered --, --QtyToDeliver = CASE QtyInStock --WHEN QtyInStock < QtyOrdered THEN QtyOrdered --ELSE QtyOrdered --END FROM Product LEFT JOIN Stock ON Product.PRODUCT_ID = Stock.PRODUCT_ID AND Stock.CLIENT_ID = 691 AND POS_ID IS NULL AND PickedDate IS NULL WHERE PRODUCT.PRODUCT_ID NOT IN (Select PRODUCT_ID FROM EXT_TYPE) Group by Product.PRODUCT_ID, Product.SortOrder order by Product.SortOrder
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.