Given the Students table:
+-----+-----------+-------+
| SId | FirstName | Score |
+-----+-----------+-------+
|   1 | Kate      |  100  |
|   2 | Misha     |    0  |
|   3 | Nick      | NULL  |
|   4 | Larisa    |  200  |
|   5 | Misha     |  150  |
|   6 | Larisa    |   50  |
|   7 | Misha     |   50  |
|   8 | Kate      |  100  |
+-----+-----------+-------+
What is the result of the following query:
SELECT MAX(SUM(Score))
FROM Students
GROUP BY FirstName;
Explanation
Aggregate functions cannot take other aggregate functions as inputs. Given query has to be rewritten in the following way:
SELECT MAX(score_sum) FROM
(SELECT SUM(Score) as score_sum
FROM Students
GROUP BY FirstName);

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes