I am trying to create a large sql statement but am stuck a bit (Well large for me!!!!!!!)
The sql statement so far is: -
cast( Product_Description as varchar) + ' (' + Department_Name + ')'
INNER JOIN dbo.Departments
on dbo.Products.DeptID = dbo.Departments.DeptID
INNER JOIN dbo.Suppliers
on dbo.Products.Supplier = dbo.Suppliers.SupplierID
INNER JOIN dbo.locations
on dbo.Products.Stock_Location = dbo.locations.LocationID
INNER JOIN dbo.Orders
on dbo.Products.ProductID = dbo.Orders.ProductID
where (dbo.Products.Qty <= Reorder_Level AND dbo.Products.logical_delete = 'false'
what I am trying to do is add dbo.products.qty in the where command to the total sum of dbo.orders.qty of the specific productID contained within dbo.orders. This statement is contained within a stored procedure.