# Write your MySQL query statement below
595. 大的国家
World
表:
+-------------+---------+ | Column Name | Type | +-------------+---------+ | name | varchar | | continent | varchar | | area | int | | population | int | | gdp | int | +-------------+---------+ name 是这张表的主键。 这张表的每一行提供:国家名称、所属大陆、面积、人口和 GDP 值。
如果一个国家满足下述两个条件之一,则认为该国是 大国 :
3000000 km2
),或者25000000
)编写一个 SQL 查询以报告 大国 的国家名称、人口和面积。
按 任意顺序 返回结果表。
查询结果格式如下例所示。
示例:
输入: World 表: +-------------+-----------+---------+------------+--------------+ | name | continent | area | population | gdp | +-------------+-----------+---------+------------+--------------+ | Afghanistan | Asia | 652230 | 25500100 | 20343000000 | | Albania | Europe | 28748 | 2831741 | 12960000000 | | Algeria | Africa | 2381741 | 37100000 | 188681000000 | | Andorra | Europe | 468 | 78115 | 3712000000 | | Angola | Africa | 1246700 | 20609294 | 100990000000 | +-------------+-----------+---------+------------+--------------+ 输出: +-------------+------------+---------+ | name | population | area | +-------------+------------+---------+ | Afghanistan | 25500100 | 652230 | | Algeria | 37100000 | 2381741 | +-------------+------------+---------+
原站题解
pythondata 解法, 执行用时: 353 ms, 内存消耗: 67.5 MB, 提交时间: 2024-05-27 13:10:04
import pandas as pd def big_countries(world: pd.DataFrame) -> pd.DataFrame: return world.loc[(world['area'] >= 3000000) | (world['population'] >= 25000000), ['name', 'area', 'population']]
mysql 解法, 执行用时: 237 ms, 内存消耗: 0 B, 提交时间: 2022-05-29 13:46:53
# Write your MySQL query statement below select name, population, area from world where area>=3000000 or population>=25000000;
mysql 解法, 执行用时: 2229 ms, 内存消耗: N/A, 提交时间: 2018-08-22 11:24:59
# Write your MySQL query statement below select name,population,area from World where area>3e6 or population>25e6;
mysql 解法, 执行用时: 3092 ms, 内存消耗: N/A, 提交时间: 2018-08-22 11:23:46
# Write your MySQL query statement below select name,population,area from World where area>3000000 or population>25000000;