Leetcode SQL 50 -- 595. Big Countries

  1. Question
    1. Table name: World
    2. Big Country
  2. Explaination
  3. Solution

Question

Table name: 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.

Big Country

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 a solution to find the name, population, and area of the big countries.
Return the result table in any order.

Explaination

Again we use SELECT <column_name> FROM <table_name> WHERE <conditions> to get the solution.

As question mention we should use OR and at least refers to >=.

Solution

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

More SQL 50 questions: here


Please cite the source for reprints, feel free to verify the sources cited in the article, and point out any errors or lack of clarity of expression. You can comment in the comments section below or email to GreenMeeple@yahoo.com
This Repo