LeetCode:595.大的国家
题目
这里有张 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 |
+--------------+-------------+--------------+
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/big-countries
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
解答
---- oracle ----
/* Write your PL/SQL query statement below */
select name,
population,
area
from World
where area > 3000000 or population > 25000000; ---- 489ms
果然是简单级别的,第一次写就通过。
拯救了我的信心。 —— 哈哈,神评论!!!
---- oracele ----
/* Write your PL/SQL query statement below */
select name,
population,
area
from World
where area > 3000000
union
select name,
population,
area
from World
where population > 25000000; --- 406ms 更快
思考
使用or
或者union
进行解题。
or
的效率很低,尽量避免使用or
最新文章
- Android中的slidingmenu
- bootstrap和bootstrap-select的outline设置
- Robot Framework自动化测试(四)--- 分层思想
- c# tcp备忘及networkstream.length此流不支持查找解决
- C# BackgroundWorker的使用【转-http://www.cnblogs.com/tom-tong/archive/2012/02/22/2363965.html】
- NSArray、NSMutableArray基本用法
- Mysql 存储过程、函数、触发器和视图的权限检查
- 正确配置jstl的maven依赖,jar包冲突的问题终于解决啦
- bzoj1492
- oracle 定位热块和热链的方法
- Android面试,与Service交互方式
- HTML5 格式化、样式、链接、表格
- Ubuntu Server 重启 Apache Mysql
- react-router 参数获取
- PHP信号管理
- GALV_maptravel研究分析(2)
- laravel5.5通过Migrations修改表 的artisan命令
- 使用UI管理docker
- 学习第一天-JAVA
- 【Linux】apt-get 源地址汇总
热门文章
- 如何将ubuntu16.04升级到ubuntu 18.04?
- shell 脚本基础与条件判断
- Des加密类
- 一百零八:CMS系统之封装权限判断功能
- 连接服务器VNC
- JAVA 基础编程练习题4 【程序 4 分解质因数】
- Python3 编程第一步_斐波纳契数列_连续赋值
- 上传NUnit的单元测试结果和OpenCover的单元测试覆盖率到SonarQube服务中
- 【Hadoop】MapReduce练习:多job关联实现倒排索引
- 线程结束,GetExitCodeThread后结束值一直STILL_ACTIVE,259的问题