File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Time: O(n)
2+ # Space: O(1)
3+
4+ # There is a table World
5+ # +-----------------+------------+------------+--------------+---------------+
6+ # | name | continent | area | population | gdp |
7+ # +-----------------+------------+------------+--------------+---------------+
8+ # | Afghanistan | Asia | 652230 | 25500100 | 20343000 |
9+ # | Albania | Europe | 28748 | 2831741 | 12960000 |
10+ # | Algeria | Africa | 2381741 | 37100000 | 188681000 |
11+ # | Andorra | Europe | 468 | 78115 | 3712000 |
12+ # | Angola | Africa | 1246700 | 20609294 | 100990000 |
13+ # +-----------------+------------+------------+--------------+---------------+
14+ #
15+ # A country is big if it has an area of bigger than 3 million square km or a population of more than 25 million.
16+ # Write a SQL solution to output big countries' name, population and area.
17+ # For example, according to the above table, we should output:
18+ # +--------------+-------------+--------------+
19+ # | name | population | area |
20+ # +--------------+-------------+--------------+
21+ # | Afghanistan | 25500100 | 652230 |
22+ # | Algeria | 37100000 | 2381741 |
23+ # +--------------+-------------+--------------+
24+
25+ SELECT name, population, area
26+ FROM World
27+ WHERE area > 3000000 OR population > 25000000 ;
You can’t perform that action at this time.
0 commit comments