-3

Can anyone please tell why is this error popping? Is there something wrong in my code?

Which Manager (ename) works only with employees who don't have the same job as he has?

Select e.ename
from emp e 
where e.job = "MANAGER" 
    and e.mgr not in (select empno from emp where job = "MANAGER")

Error in query: FEHLER: Spalte >>MANAGER<< existiert nicht LINE 1: Select e.ename from emp e where e.job = "MANAGER" and e.mgr ...

Image:

enter image description here

CarenRose
  • 1,266
  • 1
  • 12
  • 24
Bhavana
  • 11
  • 1
  • 4
  • 1
    Edit the question add some sample data & desired result as text not as image would helpful. – Yogesh Sharma Dec 06 '18 at 17:35
  • 1
    Welcome to Stack Overflow. [Please avoid pictures of code or data.](https://meta.stackoverflow.com/a/285557/5790584) Among other things, it makes it impossible to copy and paste text to try to help. – Eric Brandt Dec 06 '18 at 17:38

1 Answers1

1

Your string literals should be enclosed in single quotes instead of double quotes.

SELECT e.ename
    FROM emp e
    WHERE e.job = 'MANAGER'
        AND e.mgr NOT IN(SELECT empno
                             FROM emp
                             WHERE job = 'MANAGER'); 

Also, based on your title, I wonder if this query shouldn't be written more generically to account for any job in common? Something like:

SELECT e.ename
    FROM emp e
    WHERE NOT EXISTS(SELECT 1
                         FROM emp em
                         WHERE em.empno = e.mgr
                             AND em.job = e.job);
Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235