Find countries with GDP exceeding the group of countries

I am trying to ask 5 SQLZoo SELECT question in SELECT tutorial

In which countries is there more GDP than in any other country in Europe? [Give a name only.]

This is my decision, which is wrong, but I do not understand why.

SELECT name FROM world WHERE gdp > ALL (SELECT gdp FROM world WHERE continent ='Europe') 

What am I doing wrong?

+4
source share
4 answers
 select name,gdp from world x where gdp > all (select gdp from world y where continent = "europe" and gdp > 0) 

you failed to check the NULL value, because if the value is zero, an unknown result will be displayed, see the link: http://dev.mysql.com/doc/refman/5.5/en/all-subqueries.html

The world table may have null values ​​for some European countries when checking your request, so it is useful to put a check to avoid null values.

+8
source
 SELECT name FROM world WHERE gdp > (SELECT MAX(gdp) FROM world WHERE continent = 'Europe') 

Using the MAX aggregation function returns the highest GDP from the subquery that you want to compare with the external query.

+2
source
 select name from world where gdp > ALL(select gdp from world where continent = 'Europe' and gdp is not null) 
0
source

I went through the questions sequentially, and for some reason Germany was in my mind from the previous question. Therefore, I had this in my request and received the correct answer. Lol try it. I am using chrome

select a name from the world where gdp> ALL (select gdp from the world where name = 'Germany' and population & lt> 0)

0
source

Source: https://habr.com/ru/post/1481511/


All Articles