Leetcode刷题118-595. 大的国家(MySQL、Oracle通用解法!!!)

Come from : [https://leetcode-cn.com/problems/big-countries/]

595. Big Countries

  • 1.Question
  • 2.Answer
  • 3.我的收获

1.Question

SQL架构
There is a table World

+-----------------+------------+------------+--------------+---------------+
| name            | continent  | area       | population   | gdp           |
+-----------------+------------+------------+--------------+---------------+
| Afghanistan     | Asia       | 652230     | 25500100     | 20343000      |
| Albania         | Europe     | 28748      | 2831741      | 12960000      |
| Algeria         | Africa     | 2381741    | 37100000     | 188681000     |
| Andorra         | Europe     | 468        | 78115        | 3712000       |
| Angola          | Africa     | 1246700    | 20609294     | 100990000     |
+-----------------+------------+------------+--------------+---------------+

A country is big if it has an area of bigger than 3 million square km or a population of more than 25 million.

Write a SQL solution to output big countries’ name, population and area.

For example, according to the above table, we should output:

+--------------+-------------+--------------+
| name         | population  | area         |
+--------------+-------------+--------------+
| Afghanistan  | 25500100    | 652230       |
| Algeria      | 37100000    | 2381741      |
+--------------+-------------+--------------+

2.Answer

easy 类型题目。简单的SQL语句查询(不多BB).

AC代码如下(Oracle也能通过):

# Write your MySQL query statement below
select name, population, area from World w
where w.area > 3000000 or w.population > 25000000

3.我的收获

fighting。。。

2019/7/8胡云层 于南京 118

你可能感兴趣的:(LeetCode从零开始)