Hello, Really Struggling on a couple of things with Oracle and was wondering if anybody here could help me. First of all I have the following statement: SELECT ename FROM emp WHERE job NOT IN ('CLERK', 'ANALYST', 'SALESMAN'); Code (markup): I need to think of another way to perform the same function, which is to give details of all employees who are not Clerks, Analysts or Salesment. I tried to have a mess around with NOT EXIST but just cannot get anything to work. Secondly I am trying to show a list of courses which no students are enrolled on. I thought the following may work SELECT COURSENAME AS Coursename FROM COURSE INNER JOIN STUDENT ON course.coursename = student.coursename GROUP BY coursename HAVING count(coursecode) >= 1; Code (markup): However that is not working I am getting the error I did try another way which ended up with it just displaying all the courses whatever number I changed the count to. Any ideas?
You could just do: WHERE job <> 'CLERK' AND job <> 'ANALYST' etc... It's uglier but is the same function. On the second, I would first double check that coursename is a valid column in the student table. Secondly, I would explicitly specify which coursename you are referring to in the query. It's ambiguous all over the place as to which coursename you mean. Should be: SELECT course.coursename AS Coursename FROM course inner join student ON course.coursename = student.coursename GROUP BY course.coursename HAVING Count(course.coursecode) >= 1; Code (markup):