I am trying to run this query
SELECT Name, Position, Salary
FROM Employee
WHERE (Salary =
(SELECT MAX(Salary)
FROM Employee))
However whenever I run it I get the following error
Error Source: SQL Server Compact ADO.NET Data Provider
Error Message: There was an error parsing the query. [Token line
number = 1, Token line offset = 69, Token in error = SELECT]
I’m wondering if this is me not undertsanding how subqueries work although my tutor assures me that the statement I am trying to run is correct, could anyone shed some light on this situation, thanks.
This should work for SQL Server:
Here is the SQL Fiddle.
–EDIT
It sounds like you are using SQL Server CE which does not fully support nested sub queries. Try something like this instead using the
INkeyword: