sql server - Issue in summing the value using sql query -
in below query have 2 tables locationproductmap , productsourceproductmap. aim multiply quantifier productsourceproductmap table currentunitprice locationproductmap table, , sum it. actual result displaying wrong result.
please help me this.
actual result 45.
productsourceproductmap
productid | quantifier| locationid ----------------------------------- 1402 1 1 1403 1 1 1404 1 1 locationproductmap
productid | locationid |currentunit cost -------------------------------------------- 1402 1 5 1403 1 5 1404 1 5 query
(select sum(lpm.currentunitprice * pspm.quatifier) locationproductmap lpm left outer bring together productsourceproductmap pspm on pspm.productid in (1402, 1404, 1403) lpm.productid in (1402, 1404, 1403) , lpm.locationid = 1 ) select sum(lpm.currentunitprice * pspm.quatifier) locationproductmap lpm left bring together productsourceproductmap pspm on pspm.productid = lpm.productid lpm.locationid = 1 , lpm.productid in (1402,1404,1403)
when joining specify link of tables in on condition. if want filter info add together where clause.
sql sql-server
No comments:
Post a Comment