1

This is my code:

SELECT s_num, SUM(qty)
FROM S,SPJ
WHERE S.s_num=SPJ.s_num1
GROUP BY s_num
HAVING SUM(qty)>1000;

but I have

syntax error: unexpected "WHERE" (where)

Please help me!

2
  • While I would agree with the answer below to change to an explicit INNER JOIN, the actual problem here appears to be the space between FROM and S. Playing around with your SQL it doesn't actually appear to be a space (ie, if I cut and past it I get the error, if I replace the space between FROM and S with a real space then it avoids the error). Commented Nov 25, 2015 at 11:25
  • Thank you very much. replacing the space with a real space works! Commented Nov 25, 2015 at 15:25

1 Answer 1

1

You can use an inner join for the same result as below :

SELECT        S.s_num, SUM(S.qty) AS Expr1
FROM            S INNER JOIN
                         SPJ ON S.s_num = SPJ.s_num1
GROUP BY S.s_num
HAVING        (SUM(S.qty) > 1000)
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.