我正在尝试检索为John Smith从事的所有项目工作的员工的SSN。具体来说,我应该展示除法运算的功能。我从教科书中有一些使用嵌套函数的示例,但是我不断收到错误“ SELECT在此位置无效输入”。
我尝试了here和here的建议。一旦创建嵌套函数,就会弹出错误消息……单独地,语句执行没有问题。
我遵循了课本中的各种示例,甚至给出了相同的错误。
# This works by itself
# smith proj nums
(SELECT Pno
FROM WORKS_ON
WHERE Essn = # smith ssn
(SELECT ssn
FROM employee
WHERE Fname="John" AND Lname="Smith"));
# This also works by itself:
# employee SSNs and projs
(SELECT Essn,Pno
from WORKS_ON);
# When nested, I get the error:
SELECT ssn
FROM EMPLOYEE
WHERE NOT EXISTS(SELECT Essn,Pno
FROM WORKS_ON
EXCEPT(SELECT Pno
FROM WORKS_ON
WHERE Essn = (SELECT ssn
FROM employee
WHERE Fname="John" AND Lname="Smith")));