I have the following SQL statement that is used to extract data from a table. S is a text field. GID and SC are Integers. The statement will extract S, GID, and SC for the greatest SC for each GID.
When I run the query, I receive the following message:
You have written a subquery that can return more than one field without using the EXISTS reserved word in the main query’s FROM clause. Revise the SELECT statement of the subquery to request only one field.
Where can I find data on the EXISTS reserved word. I searched the Help File and Microsoft Knowledge base but have not had any luck. Can the below statement be used to retrieve the results.
SELECT Table1.S, TABLE1.GID, TABLE1.SC
FROM TABLE1
WHERE (TABLE1.GID, TABLE1.SC) IN(
SELECT Table1.GID, Max(Table1.SC) AS MaxOfSC
FROM Table1
GROUP BY Table1.GID);
Please note that the following SQL script does work, however, I am curious to find out about the Exists reserve word.
SELECT [TABLE1]., [TABLE1].[GID], [TABLE1].[SC]
FROM TABLE1
WHERE TABLE1.GID&”_”&TABLE1.SC IN (SELECT TABLE1.GID&”_”& Max(TABLE1.SC) AS MaxOfSC FROM TABLE1 GROUP BY TABLE1.GID);