SQL逻辑运算符

时间:2012-11-09 20:21:40

标签: sql oracle

哪些职业不是学生,律师或教育工作者?按字母顺序降序列出它们?

SELECT Occupation 
  FROM Viewer 
 WHERE occupation NOT IN 'student,lawyer,educator' 
ORDER BY occupation desc; 

我一直收到错误。我做错了什么?

1 个答案:

答案 0 :(得分:6)

IN需要括号括起来的表达式列表:

SELECT Occupation
FROM Viewer
WHERE occupation NOT IN ('student','lawyer','educator')
ORDER BY occupation desc;

请参阅documentation for IN以查看正确的语法:

IN condition