Houdini211
Houdini211

Reputation: 1

Simple Subquery Statement, receiving an error

We are learning subqueries in Oracle SQL. I'm receiving an error "SQL command not properly ended" with an example from my textbook that should work.

I have attempted re-spacing the subquery, but keeping the exact code, this should work

SELECT last_name, salary
FROM employees
WHERE salary > 11000
                (SELECT salary
                 FROM employees
                 WHERE last_name='Abel');

ERROR at line 4: ORA-00933: SQL command not properly ended

Upvotes: 0

Views: 49

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1269503

Is this what you want?

SELECT last_name, salary
FROM employees
WHERE salary > 11000 AND
      last_name = 'Abel';

This would return employees named "Abel" whose salary exceeds 11,000.

Upvotes: 0

There needs to be something between the 11000 and the following subselect. As an example, it might be that the following was intended:

SELECT last_name, salary
FROM employees
WHERE salary > 11000 AND
      salary IN (SELECT salary
                 FROM employees
                 WHERE last_name='Abel');

Upvotes: 2

Related Questions