Skip to content
Advertisement

How do i write this without using ALL?

Write a query to find only those customers whose grade are, higher than every customer to the city New York

Advertisement

Answer

You can use MAX in your subquery instead:

As @GordonLinoff points out, if there are no customers from New York, this query will fail. You can work around that by using COALESCE to convert the MAX value from NULL to -1 (basically you need a number which is lower than the lowest possible value of grade) e.g.

Demo on dbfiddle

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement