Find big countries by area or population threshold

Quick Overview

Write a SQL query that lists the name, population and area of every country that meets an area threshold or a population threshold, where a value equal to the threshold passes. It tests WHERE filters with OR, inclusive comparisons and how NULL values behave in a boolean condition.

Find big countries by area or population threshold

Company: Adobe

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

A country is big if its area is at least 3,000,000 km² or its population is at least 25,000,000. Write a query that returns the `name`, `population` and `area` of every big country in the `World` table, ordered by `name`. ```hint Check the thresholds Count the zeros in each threshold, and check what should happen to a value exactly equal to one. ``` ### Input Table(s) `World` | Column | Type | Meaning | |---|---|---| | name | VARCHAR(255) | Country name, primary key | | continent | VARCHAR(255) | Continent the country is on | | area | INT | Area in square kilometers | | population | BIGINT | Number of inhabitants | | gdp | BIGINT | Gross domestic product. Not needed for this query. | Keys: `name` is the primary key, so each country appears in exactly one row. ### Output Contract | Column | Type | Meaning | |---|---|---| | name | VARCHAR | Country name | | population | BIGINT | Population as stored | | area | INT | Area as stored | - Columns in this order: `name`, `population`, `area`. - One row per big country. - Order by `name` ascending. `name` is the primary key, so the order is unique. - No rounding or unit conversion. ### Example `World` | name | continent | area | population | gdp | |---|---|---|---|---| | Arland | Europe | 3000000 | 1200000 | 45000000000 | | Borovia | Asia | 450000 | 25000000 | 310000000000 | | Calderra | Africa | 2999999 | 24999999 | 98000000000 | | Dunmore | Oceania | 7600000 | 26000000 | 1500000000000 | | Estavia | Europe | 120000 | 9000000 | 210000000000 | Expected result: | name | population | area | |---|---|---| | Arland | 1200000 | 3000000 | | Borovia | 25000000 | 450000 | | Dunmore | 26000000 | 7600000 | Arland qualifies on area alone with a value exactly at the threshold, and Borovia qualifies on population alone at exactly 25,000,000. Dunmore passes both tests and still appears once. Calderra misses each threshold by one, and Estavia misses both. ### Constraints and Clarifications - `World` has at most 500 rows. - `area` and `population` are non-negative integers. - Both thresholds are inclusive: a value equal to the threshold passes. - Meeting either threshold is enough. A country that meets both appears once. - The columns have no NOT NULL constraint. If one of `area` or `population` is NULL, judge the country on the other value alone. A country with both values NULL is not big.

Overview: Write a SQL query that lists the name, population and area of every country that meets an area threshold or a population threshold, where a value equal to the threshold passes. It tests WHERE filters with OR, inclusive comparisons and how NULL values behave in a boolean condition.

Adobe logo
Adobe
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

A country is big if its area is at least 3,000,000 km² or its population is at least 25,000,000. Write a query that returns the name, population and area of every big country in the World table, ordered by name.

Input Table(s)

World

ColumnTypeMeaning
nameVARCHAR(255)Country name, primary key
continentVARCHAR(255)Continent the country is on
areaINTArea in square kilometers
populationBIGINTNumber of inhabitants
gdpBIGINTGross domestic product. Not needed for this query.

Keys: name is the primary key, so each country appears in exactly one row.

Output Contract

ColumnTypeMeaning
nameVARCHARCountry name
populationBIGINTPopulation as stored
areaINTArea as stored
  • Columns in this order: name , population , area .
  • One row per big country.
  • Order by name ascending. name is the primary key, so the order is unique.
  • No rounding or unit conversion.

Example

World

namecontinentareapopulationgdp
ArlandEurope3000000120000045000000000
BoroviaAsia45000025000000310000000000
CalderraAfrica29999992499999998000000000
DunmoreOceania7600000260000001500000000000
EstaviaEurope1200009000000210000000000

Expected result:

namepopulationarea
Arland12000003000000
Borovia25000000450000
Dunmore260000007600000

Arland qualifies on area alone with a value exactly at the threshold, and Borovia qualifies on population alone at exactly 25,000,000. Dunmore passes both tests and still appears once. Calderra misses each threshold by one, and Estavia misses both.

Constraints and Clarifications

  • World has at most 500 rows.
  • area and population are non-negative integers.
  • Both thresholds are inclusive: a value equal to the threshold passes.
  • Meeting either threshold is enough. A country that meets both appears once.
  • The columns have no NOT NULL constraint. If one of area or population is NULL, judge the country on the other value alone. A country with both values NULL is not big.