We help IT Professionals succeed at work.

sql 2008  sub query

This is the code that I am entering:
SELECT LastName
FROM Employees
WHERE NOT Title = (SELECT Title FROM Employees WHERE LastName = 'Davolio')
This is my error message:

Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.


What am I doing wrong?

Comment
Watch Question

Commented:
try...

SELECT LastName
FROM Employees
WHERE Title not in  (SELECT Title FROM Employees WHERE LastName = 'Davolio')
Rajkumar GsSoftware Engineer
Commented:
carsRST corrected the query right.

Error is because the subquery return more than one record and will clash with = of main query. If you use =, then sub-query is meant to return only one record. If you meant for multiple records, always use 'IN' operator.

Raj