Interview Questions/SQL/Big Countries

Big Countries

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Description

You are given a World table containing information about countries. A country is considered big if: - it has an area of at least 3,000,000 km², OR - it has a population of at least 25,000,000. Write a SQL query to find the name, population, and area of all big countries. Return the result in any order.

Database Schema

World

Column NameExample Value
nameAfghanistan
continentAsia
area652230
population25500100
gdp20343000000

Example

World

namecontinentareapopulationgdp
AfghanistanAsia6522302550010020343000000
AlbaniaEurope28748283174112960000000
AlgeriaAfrica238174137100000188681000000
AndorraEurope468781153712000000
AngolaAfrica124670020609294100990000000

Output

namepopulationarea
Afghanistan25500100652230
Algeria371000002381741

Explanation:

Afghanistan qualifies because its population (25500100) >= 25000000. Algeria qualifies because its population (37100000) >= 25000000. Albania, Andorra, and Angola do not meet either condition.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

SQL Editor
Loading...

World

namecontinentareapopulationgdp
AfghanistanAsia6522302550010020343000000
AlbaniaEurope28748283174112960000000
AlgeriaAfrica238174137100000188681000000
AndorraEurope468781153712000000
AngolaAfrica124670020609294100990000000

Output

namepopulationarea
Afghanistan25500100652230
Algeria371000002381741