I\'m trying to write a query that will list student(s) enrolled with the maximum total credit points.
Here is my query:
SELECT s.S_ID,
s.S_LAS
Removing all the "noise" your query become
SELECT s.S_ID, s.S_LAST, s.S_FIRST, s."Total Credits"
FROM
(SELECT ...
FROM (...) q1
JOIN (...) q2
) q3
GROUP BY s.S_ID, s.S_LAST, s.S_FIRST, s."Total Credits"
WHERE "Total Credits" = max("Total Credits");
It's easy to see that s
is not visible from your main query, also in the WHERE
condition you're confronting a detail with an aggregation, that's not possible (at least not that way)