troubleshooting Question

sql statement syntax

Avatar of ljhodgett
ljhodgett asked on
Microsoft SQL ServerMicrosoft SQL Server 2005SQL
13 Comments1 Solution301 ViewsLast Modified:

I am trying to create a large sql statement but am stuck a bit (Well large for me!!!!!!!)

The sql statement so far is: -

            Select      ProductID,

                        cast( Product_Description as varchar) + ' (' + Department_Name + ')'
                        as Product_Req

            from dbo.Products
                  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.

Best Regards

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros