ckp25
ckp25

Reputation: 33

SQL logical operator

What are the occupations that are NOT student, lawyer or educator? List them in descending alphabetical order?

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

I keep getting an error. What am i doing wrong?

Upvotes: 3

Views: 157

Answers (1)

Mark Byers
Mark Byers

Reputation: 837926

IN requires a list of expressions surrounded by parentheses:

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

See the documentation for IN to see the correct syntax:

IN condition

Upvotes: 6

Related Questions