0

I have this mysql query that I'm running with php, but I don't really know whats wrong on it, can somebody help me?

SELECT OrderID, SUM(Quantity) AS Total FROM OrderDetails 
GROUP BY OrderID WHERE ProductID BETWEEN 11 AND 14;
3
  • Do you get an error, what does it say? Commented Feb 12, 2015 at 10:45
  • @randomizer " Syntax error (missing operator) in query expression 'OrderID WHERE ProductID BETWEEN 11 AND 14' " I'm running my mysql query here: w3schools.com/sql/trysql.asp?filename=trysql_func_sum Commented Feb 12, 2015 at 10:46
  • Like Puneet statet below, your GROUP BY statement should be placed at the end of your query. Commented Feb 12, 2015 at 10:48

1 Answer 1

3

Use the following :-

SELECT OrderID, SUM(Quantity) AS Total 
FROM OrderDetails 
WHERE ProductID BETWEEN 11 AND 14 
GROUP BY OrderID;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.