The following statement doesn't return anything even though it executes successfully. I really don't even want to use all the variables but the one that I need is the @ordTotal because I'm using that in the HAVING clause. How do I code this to where I can have the check in the HAVING clause?
Thanks!Code:SELECT @custID = Customers.CustomerID ,@company = Customers.CompanyName ,@orderID = Orders.OrderID ,@ordDate = Format(Orders.OrderDate, 'd','us') ,@prodID = [Order Details].ProductID ,@prodName = Products.ProductName ,@unitPrice = [Order Details].UnitPrice ,@qty = [Order Details].Quantity ,@discount = [Order Details].Discount ,@ordTotal = ([Order Details].UnitPrice * [Order Details].Quantity) FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID INNER JOIN Products ON [Order Details].ProductID = Products.ProductID GROUP BY Customers.CustomerID ,Customers.CompanyName ,Orders.OrderID ,Orders.OrderDate ,[Order Details].ProductID ,Products.ProductName ,[Order Details].UnitPrice ,[Order Details].Quantity ,[Order Details].Discount HAVING SUM(@ordTotal) > 15000;




Reply With Quote