Basic Join

Population Census

select sum(ct.POPULATION) from CITY ct, COUNTRY cntry
where ct.COUNTRYCODE = cntry.CODE
and cntry.CONTINENT = 'Asia';

African Cities

select ct.NAME from CITY ct, COUNTRY cntry
where ct.COUNTRYCODE = cntry.CODE
and cntry.CONTINENT = 'Africa';

Average Population of Each Continent

select COUNTRY.CONTINENT, floor(avg(CITY.POPULATION))
from CITY, COUNTRY
where CITY.COUNTRYCODE = COUNTRY.CODE
group by COUNTRY.CONTINENT;

The Report

SELECT 
    CASE WHEN Grades.Grade<8 THEN NULL ELSE Students.Name END,
    Grades.Grade,
    Students.Marks
FROM Students JOIN Grades 
ON Students.Marks BETWEEN Grades.Min_Mark AND Grades.Max_Mark
ORDER BY Grades.Grade DESC, Students.Name, Students.Marks

Last updated

Was this helpful?