The big Countries interview question is very easy and asked in many interviews for beginners.


 Let's start with the table schema of World:


CREATE TABLE World (name varchar(255), continent varchar(255), area int, population int, gdp int)


INSERT INTO World (name, continent, area, population, gdp) values ('Afghanistan', 'Asia', '652230', '25500100', '20343000000')

INSERT INTO World (name, continent, area, population, gdp) values ('Albania', 'Europe', '28748', '2831741', '12960000000')

INSERT INTO World (name, continent, area, population, gdp) values ('Algeria', 'Africa', '2381741', '37100000', '188681000000')

INSERT INTO World (name, continent, area, population, gdp) values ('Andorra', 'Europe', '468', '78115', '3712000000')

INSERT INTO World (name, continent, area, population, gdp) values ('Angola', 'Africa', '1246700', '20609294', '100990000000')


The table World will look like this,


name continent area population gdp
Afghanistan Asia 652230 25500100 20343000000
Albania Europe 28748 2831741 12960000000
Algeria Africa 2381741 37100000 188681000000
Andorra Europe 468 78115 3712000000
Angola Africa 1246700 20609294 100990000000


Question: A country is big if:

  • it has an area of at least three million (i.e., 3000000 km2), or
  • it has a population of at least twenty-five million (i.e., 25000000).
Write an SQL query to report the name, population, and area of the big countries.


The query result table will be:

 
name population area
Afghanistan 25500100 652230
Algeria 37100000 2381741


You have checked the question and table schema and also the result table. This is very easy for you to write a query.

So let's start with the result query:

SELECT name, population, area FROM World WHERE population>='25000000' OR area>='3000000';


This is the query that will produce the required output. 

If you have any doubts or queries, please let us know in the comments.