|
| 1 | +/* |
| 2 | +Problem Description: |
| 3 | + |
| 4 | ++-------------+---------+ |
| 5 | +| Column Name | Type | |
| 6 | ++-------------+---------+ |
| 7 | +| name | varchar | |
| 8 | +| continent | varchar | |
| 9 | +| area | int | |
| 10 | +| population | int | |
| 11 | +| gdp | bigint | |
| 12 | ++-------------+---------+ |
| 13 | +name is the primary key column for this table. |
| 14 | +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. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +A country is big if: |
| 19 | + |
| 20 | + it has an area of at least three million (i.e., 3000000 km2), or |
| 21 | + it has a population of at least twenty-five million (i.e., 25000000). |
| 22 | + |
| 23 | +Write an SQL query to report the name, population, and area of the big countries. |
| 24 | + |
| 25 | +Return the result table in any order. |
| 26 | + |
| 27 | +The query result format is in the following example. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +Example 1: |
| 32 | + |
| 33 | +Input: |
| 34 | +World table: |
| 35 | ++-------------+-----------+---------+------------+--------------+ |
| 36 | +| name | continent | area | population | gdp | |
| 37 | ++-------------+-----------+---------+------------+--------------+ |
| 38 | +| Afghanistan | Asia | 652230 | 25500100 | 20343000000 | |
| 39 | +| Albania | Europe | 28748 | 2831741 | 12960000000 | |
| 40 | +| Algeria | Africa | 2381741 | 37100000 | 188681000000 | |
| 41 | +| Andorra | Europe | 468 | 78115 | 3712000000 | |
| 42 | +| Angola | Africa | 1246700 | 20609294 | 100990000000 | |
| 43 | ++-------------+-----------+---------+------------+--------------+ |
| 44 | +Output: |
| 45 | ++-------------+------------+---------+ |
| 46 | +| name | population | area | |
| 47 | ++-------------+------------+---------+ |
| 48 | +| Afghanistan | 25500100 | 652230 | |
| 49 | +| Algeria | 37100000 | 2381741 | |
| 50 | ++-------------+------------+---------+ |
| 51 | + |
| 52 | +*/ |
| 53 | + |
| 54 | +# Write your MySQL query statement below |
| 55 | + |
| 56 | +SELECT name, population, area |
| 57 | +FROM world |
| 58 | +WHERE area >= 3000000 or population >= 25000000 |
0 commit comments