返回介绍

solution / 0500-0599 / 0595.Big Countries / README_EN

发布于 2024-06-17 01:03:36 字数 2791 浏览 0 评论 0 收藏 0

595. Big Countries

中文文档

Description

Table: World

+-------------+---------+
| Column Name | Type  |
+-------------+---------+
| name    | varchar |
| continent   | varchar |
| area    | int   |
| population  | int   |
| gdp     | bigint  |
+-------------+---------+
name is the primary key (column with unique values) for this table.
Each row of this table gives information about the name of a country, the continent to which it belongs, its area, the population, and its GDP value.

 

A country is big if:

  • it has an area of at least three million (i.e., 3000000 km2), or
  • it has a population of at least twenty-five million (i.e., 25000000).

Write a solution to find the name, population, and area of the big countries.

Return the result table in any order.

The result format is in the following example.

 

Example 1:

Input: 
World table:
+-------------+-----------+---------+------------+--------------+
| 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 |
+-------------+-----------+---------+------------+--------------+
Output: 
+-------------+------------+---------+
| name    | population | area  |
+-------------+------------+---------+
| Afghanistan | 25500100   | 652230  |
| Algeria   | 37100000   | 2381741 |
+-------------+------------+---------+

Solutions

Solution 1

# Write your MySQL query statement below
SELECT name, population, area
FROM World
WHERE area >= 3000000 OR population >= 25000000;

Solution 2

# Write your MySQL query statement below
SELECT name, population, area
FROM World
WHERE area >= 3000000
UNION
SELECT name, population, area
FROM World
WHERE population >= 25000000;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文