#470 SQL Queries for Countries, Population, and GDP
The following tables are given:
CREATE TABLE country (
id SERIAL
name VARCHAR(100)
continent VARCHAR(50)
population INT
);
CREATE TABLE gdp (
id
country_id INT
year INT
value INT
);
Required:
- Return continents and the total population of each;
- Return continents and the total population of each where the population exceeds one billion;
- Return the country name and GDP per capita;
- Explain errors involving NULL and 0;
-
There are 200 rows in the country table and 180 in
gdp. How many rows will the query return? Explain using set theory; - Return the continent, country name, and population. Show only the largest country by population on each continent;
- The same as item 6, but return the top 3 countries.
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor