Skip to content

Commit f2d7153

Browse files
authored
Create big-countries.sql
1 parent e470868 commit f2d7153

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

MySQL/big-countries.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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;

0 commit comments

Comments
 (0)