Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Query not returning all rows

$
0
0

I'm trying to set a query that will return all products that a load requires along with the amount that has been allocated to it. I have this semi working, only thing is it will only provide me with a product that has an allocated quantity already. A little help please.

Select  P.ProductDescription as Product, ISNULL(SUM(PD.CaseQty),0) as AllocatedQty, L.Qty as RequiredQty
	From 	PalletDetail PD 
	Inner Join 
	RunHeaders R on PD.RunId = R.RunId
	Inner Join
	Products P on P.ProductId = R.ProductId
	Inner Join
	LoadProduct L on L.ProductId = P.ProductId
	Where 	PD.LoadId 	= @LoadId And PD.RunId = R.RunId And PD.LoadId = L.LoadId And R.ProductId = P.ProductId And R.ProductId = L.ProductId
	Group By L.LoadId, P.ProductId, P.ProductDescription, L.Qty


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>