while select sum(PostedQty),sum(Received),sum(Deducted), sum(Registered),sum(Picked) from inventSum group by itemId where inventSum.ItemId == _itemId && inventSum.Closed == NoYes::No join inventDim group by InventSiteId, InventLocationId,wMSLocationId where inventDim.inventDimId == inventSum.InventDimId { inventQtyPhysicalOnhand = inventSum.PostedQty + inventSum.Received - inventSum.Deducted + inventSum.Registered - inventSum.Picked; }