Select Countries Passing Either Big-Country Threshold

Quick Overview

Return countries with at least 3,000,000 square kilometers of area or at least 25,000,000 residents.

Select Countries Passing Either Big-Country Threshold

Company: Google

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

### Problem Report name, population and area for countries whose area is at least 3,000,000 square kilometers or whose population is at least 25,000,000. Satisfying either threshold is enough, including equality. Result row order is unrestricted. ### Tables Table: `World` ```text +-------------+---------+ | Column Name | Type | +-------------+---------+ | name | varchar | | continent | varchar | | area | int | | population | int | | gdp | bigint | +-------------+---------+ name is the primary key (column with unique values) for this table. Each row of this table gives information about the name of a country, the continent to which it belongs, its area, the population, and its GDP value. ``` ### Example ```text World (name,continent,area,population,gdp): (Aland,North,3000000,5,100), (Bland,South,8,25000000,200), (Cland,North,2999999,24999999,300) Output (name,population,area): (Aland,5,3000000), (Bland,25000000,8) ``` ### What a Strong Answer Covers - Include each country that satisfies at least one threshold. - Keep countries that meet a threshold exactly and return the requested fields. ### Follow-up Questions - How would you return a column showing which threshold each country met? - How would you make the thresholds configurable?

Overview: Return countries with at least 3,000,000 square kilometers of area or at least 25,000,000 residents.

Google logo
Google
easySoftware EngineerOtherData Manipulation (SQL/Python)
0
0

Problem

Report name, population and area for countries whose area is at least 3,000,000 square kilometers or whose population is at least 25,000,000. Satisfying either threshold is enough, including equality. Result row order is unrestricted.

Tables

Table: World

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| name        | varchar |
| continent   | varchar |
| area        | int     |
| population  | int     |
| gdp         | bigint  |
+-------------+---------+
name is the primary key (column with unique values) for this table.
Each row of this table gives information about the name of a country, the continent to which it belongs, its area, the population, and its GDP value.

Example

World (name,continent,area,population,gdp): (Aland,North,3000000,5,100), (Bland,South,8,25000000,200), (Cland,North,2999999,24999999,300)
Output (name,population,area): (Aland,5,3000000), (Bland,25000000,8)

What a Strong Answer Covers Guidance

  • Include each country that satisfies at least one threshold.
  • Keep countries that meet a threshold exactly and return the requested fields.

Follow-up Questions Guidance

  • How would you return a column showing which threshold each country met?
  • How would you make the thresholds configurable?