zoukankan      html  css  js  c++  java
  • [SQL]LeetCode595. 大的国家 | Big Countries

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
    ➤微信公众号:山青咏芝(shanqingyongzhi)
    ➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/
    ➤GitHub地址:https://github.com/strengthen/LeetCode
    ➤原文地址:https://www.cnblogs.com/strengthen/p/10450247.html 
    ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
    ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

    SQL架构

    1 Create table If Not Exists World (name varchar(255), continent varchar(255), area int, population int, gdp int)
    2 Truncate table World
    3 insert into World (name, continent, area, population, gdp) values ('Afghanistan', 'Asia', '652230', '25500100', '20343000000')
    4 insert into World (name, continent, area, population, gdp) values ('Albania', 'Europe', '28748', '2831741', '12960000000')
    5 insert into World (name, continent, area, population, gdp) values ('Algeria', 'Africa', '2381741', '37100000', '188681000000')
    6 insert into World (name, continent, area, population, gdp) values ('Andorra', 'Europe', '468', '78115', '3712000000')
    7 insert into World (name, continent, area, population, gdp) values ('Angola', 'Africa', '1246700', '20609294', '100990000000')

    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      |
    +--------------+-------------+--------------+

    这里有张 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     |
    +-----------------+------------+------------+--------------+---------------+
    

    如果一个国家的面积超过300万平方公里,或者人口超过2500万,那么这个国家就是大国家。

    编写一个SQL查询,输出表中所有大国家的名称、人口和面积。

    例如,根据上表,我们应该输出:

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

    1613ms
    1 # Write your MySQL query statement below
    2 select 
    3     a.name, a.population, a.area
    4 from 
    5     world as a
    6 where 
    7     a.area > 3000000 or a.population > 25000000

    1627ms

    1 # Write your MySQL query statement below
    2 select w.name, w.population, w.area
    3 from World w
    4 where w.area > 3000000 or
    5       w.population > 25000000;  
  • 相关阅读:
    java.math.BigDecimal
    抽象类和接口的区别:
    idea 快捷键
    java 抽象类
    mongodb3.2系统性学习——5、游标 模糊查询 findAndModify函数
    ZeroClipboard2.0 复制功能
    MySQL在远程访问时非常慢的解决skip-name-resolve 并且出现 Reading from net
    mongodb3.2系统性学习——2、write concern mongodb 写安全机制
    mysql 存储引擎 myisam innodb 区别
    MYSQL 错误 :Out of resources when opening file './datagather/mx_domain#P#p178.MYD' (Errcode: 24) 解决办法
  • 原文地址:https://www.cnblogs.com/strengthen/p/10450247.html
Copyright © 2011-2022 走看看