Alex Rivera | Logout

sql sub-queries

Asked 2011-06-17T12:27:12.713
9

Can anyone help me with the following:

Some countries have populations more than three times that of any of their neighbours (in the same region). Give the countries and regions.

my try:

select x.name, x.region
from bbc x
where x.population >all
(select population*3
from bbc y
where y.region = x.region)

syntax is correct but no records are returned (should return 3 rows)

Find each country that belongs to a region where all populations are less than 25000000. Show name, region and population.

my try:

select name, region, population
from bbc
where region not in 
(select distinct region from bbc 
where population >= 25000000)

I used "not in". Is there a way to use "in" ?

Edit
Report

1 Answer

1
select name, region from bbc x
where population > all
(select 3*population from bbc y 
where y.region=x.region and population > 0 and x.name <> y.name)
answered 2012-07-30T22:41:49.877

Your Answer