1

In the below query I have 2 tables locationproductmap and productsourceproductmap. My aim is to multiply the quantifier from the productsourceproductmap table with CurrentUnitPrice from the locationproductmap table, and then sum it. But my actual result is displaying incorrect result.

Please help me to do this.

Actual result is 45.

productsourceproductmap

Productid  | Quantifier| locationId
-----------------------------------
1402              1            1
1403              1            1
1404              1            1

locationproductmap

ProductId    | Locationid |CurrentUnit Price
--------------------------------------------
1402              1            5
1403              1            5
1404              1            5   

Query

(Select  
     SUM(LPM.CurrentUnitPrice * PSPM.Quatifier) 
 From 
     LocationProductMap LPM 
 LEFT OUTER JOIN
     ProductSourceProductMap PSPM ON PSPM.ProductID IN (1402, 1404, 1403)  
 WHERE 
     LPM.ProductID IN (1402, 1404, 1403) 
     AND LPM.LocationID = 1
)     

1 Answer 1

2
Select  SUM(LPM.CurrentUnitPrice * PSPM.Quatifier) 
From LocationProductMap LPM 
LEFT Join ProductSourceProductMap PSPM ON PSPM.ProductID = LPM.ProductID 
WHERE LPM.LocationID = 1
AND LPM.ProductID IN (1402,1404,1403)

When joining specify the link of the tables in the ON condition. If you want to filter the data then add that to your where clause.

Sign up to request clarification or add additional context in comments.

2 Comments

ProductID IN (1402,1404,1403)
Can you be more specific?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.