Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL Programming 


Sub-Queries Question


Employees - Imgur: The magic of the Internet[^]

What I have tried:

SELECT FNAME, LNAME, DEPT
FROM Employees
WHERE salary = (SELECT MIN(salary) FROM Employees WHERE BUILDING = 400 OR BUILDING = 402 OR BUILDING = 405);


ERROR:
Data type mismatch in criteria expression


How do I fix it?
Posted
Updated 13-Nov-18 19:23pm

1 solution

Start by looking at your data: at a guess, the BUILDING column contains non-numeric data.

If BUILDING is supposed to be numeric, then store it in a numeric field : INT is good. If it isn't, then use a string comparison:
SQL
... FROM Employees WHERE BUILDING = '400' OR BUILDING = '402' OR ...

Or
SQL
... FROM Employees WHERE BUILDING IN ('400', '402', '405'));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900