S
S
Senture2019-03-21 21:20:16
SQL
Senture, 2019-03-21 21:20:16

Compare 1 row (namely a field) with n other fields, how?

Hello, I have this request:

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

But it doesn't work because the parenthesized SELECT returns a lot of rows.
How can this task be accomplished?
PS in sql I'm still 0, thank you very much for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2019-03-21
@Senture

Depends on what you want to select and what your query returns. If you need to select records whose gdp is greater than the maximum for records with continent = 'Europe', then this is done

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

If something else - specify what you store and what you want.
And, it would also be nice to clarify what you have - MS SQL, MySQL or something else

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question