-- 3.1

select AVG(length)
from river
where Sea = "Black Sea"

-- 3.2

select river.name, count(distinct geo_river.country)
from river
join geo_river on river.name = geo_river.river
where river.sea = "Mediterranean Sea"
group by river.name

-- 3.3

select organization.name, sum(country.population)
from organization
join ismember on ismember.organization = organization.abbreviation
join country on country.code = ismember.country
group by organization.name
having count(*) > 100

-- 3.4

select country.name, moutain.name, max(moutain.height)
from mountain
join geo_moutain on geo_mountain.mountain = moutain.name
join country on geo_mountain.country = country.code
join encompasses on encompasses.country = country.code
where encompasses.continent = "America"
group by country.name

-- 4.1

-- 4.2

select name from river where river = "Nile" 
union 
select name from river where river in (select name from river where river = "Nile")

-- 4.3

select name, population
from (
	select country.name, country.population
	from country
	join borders on country.code = borders.country1
