I came across multiple queries which use the all quantor for a max subquery:
Is there any difference between
SELECT name FROM bbc
WHERE population > ALL
(SELECT MAX(population)
FROM bbc
WHERE region = 'Europe')
AND region = 'South Asia'
and
SELECT name FROM bbc
WHERE population >
(SELECT MAX(population)
FROM bbc
WHERE region = 'Europe')
AND region = 'South Asia'
?
SELECT MAX
is an aggregate operation and, therefore, your subquery will select a single row.
Applying ALL
to a single row will have no effect.
If your subquery returned multiple rows, the non-ALL
version would result in an error. Also note that when using ALL
, you could remove the MAX
from the subquery and you'd get correct results (presumably with the same performance characteristics).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With