Doesn't equal, doesn't work in sql query

Hi I tried to get data from tables using below query but doesn't work.

    SELECT
    ProductMaster.ProductName + '(' + CONVERT(nvarchar(10), 0) + ')' AS orderedproducts,
    BranchName + '(' + CONVERT(nvarchar(10), SUM(StockInward.Qty)) + ')' AS currentstock,
    Setup.Id AS BranchId
FROM ProductMaster
INNER JOIN StockOutward
    ON ProductMaster.Productid = StockOutward.productid
INNER JOIN stockinward
    ON ProductMaster.Productid = stockinward.productid
    AND stockinward.StockLocation <> StockOutward.Location
INNER JOIN Setup
    ON stockinward.stocklocation = Setup.id
WHERE StockOutward.ProductId = '7'
GROUP BY    ProductMaster.ProductName,
            StockOutward.Qty,
            BranchName,
            Setup.Id

      

It displays all records from the table StockOutward

.

+3


source to share


1 answer


Try it In your inner join move your <> to the where clause. And in your example, try a simpler query (select one simple element and add innerjoin one by one.



0


source







All Articles