I’m trying to learn sql and I get this error – what does it mean?.
I’m trying to : Get countries that have a GDP greater than any country in Europe?
Error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Subquery returned more
than 1 value. This is not permitted when the subquery follows =, !=,
<, <= , >, >= or when the subquery is used as an expression.
(SQL-21000)
select name, gdp from bbc
where gdp >
(
select gdp from bbc
where region = 'Europe'
)
The message describes the error adequately: your table has many countries in Europe, so
>operator cannot be applied without some aggregation or more constraints in the subquery:Adding
maxensures that there would be precisely one number selected, and that number is the highest GDP among all European countries1.1 You might as well select the GDP of Germany right away 🙂