Reputation: 1793
I have found some question about this error which was previously asked but those are not perfectly what i am looking. This is why I have to asked here.
I am getting ORA-00933: SQL command not properly ended
error while running this query.
select T.course_id from course as T
where unique (select R.course_id from section as R
where T.course_id= R.course_id and R.year = 2009);
Here is the screenshot:
Now, what's wrong with this query ? How do I solve this error?
Upvotes: 0
Views: 202
Reputation: 1269443
The problem is the as
. Oracle does not recognize that for table aliases. However, I don't understand what distinct
is doing; perhaps you mean exists
:
select T.course_id
from course T
where exists (select R.course_id
from section R
where T.course_id= R.course_id and R.year = 2009
);
EDIT:
If you want to validate that all courses in the subquery are distinct and if the database does not support unique
(which may be an ANSI operator but I'm not sure it is implemented elsewhere):
select T.course_id
from course T
where 1 = (select (case when count(R.course_id) = count(distinct R.course_id) and
count(R.courseJ_id) = count(*)
then 1 else 0
end)
from section R
where T.course_id= R.course_id and R.year = 2009
);
Upvotes: 2