this will give you quantity remaining for a prdt between two dates
SELECT p.ProductName,COALESCE(bp.Quantity,0) AS BookedQty, p.Quantity - COALESCE(bp.Quantity,0) AS RemainingStock
FROM Product p
LEFT JOIN ( SELECT ProductID,SUM(Quantity) AS TotalQty
FROM BookedProduct bp1
INNER JOIN BookingDetails bd
ON bd.CustomerID = bp1.CustomerID
WHERE @Date >= bd.DateFrom AND @Date < bd.DateTo +1
GROUP BY ProductID
)bp
ON bp.ProductID = p.ProductID
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/