题目链接:https://leetcode-cn.com/problems/big-countries/

题目

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

最新文章

  1. Android中的slidingmenu
  2. bootstrap和bootstrap-select的outline设置
  3. Robot Framework自动化测试(四)--- 分层思想
  4. c# tcp备忘及networkstream.length此流不支持查找解决
  5. C# BackgroundWorker的使用【转-http://www.cnblogs.com/tom-tong/archive/2012/02/22/2363965.html】
  6. NSArray、NSMutableArray基本用法
  7. Mysql 存储过程、函数、触发器和视图的权限检查
  8. 正确配置jstl的maven依赖,jar包冲突的问题终于解决啦
  9. bzoj1492
  10. oracle 定位热块和热链的方法
  11. Android面试,与Service交互方式
  12. HTML5 格式化、样式、链接、表格
  13. Ubuntu Server 重启 Apache Mysql
  14. react-router 参数获取
  15. PHP信号管理
  16. GALV_maptravel研究分析(2)
  17. laravel5.5通过Migrations修改表 的artisan命令
  18. 使用UI管理docker
  19. 学习第一天-JAVA
  20. 【Linux】apt-get 源地址汇总

热门文章

  1. 如何将ubuntu16.04升级到ubuntu 18.04?
  2. shell 脚本基础与条件判断
  3. Des加密类
  4. 一百零八:CMS系统之封装权限判断功能
  5. 连接服务器VNC
  6. JAVA 基础编程练习题4 【程序 4 分解质因数】
  7. Python3 编程第一步_斐波纳契数列_连续赋值
  8. 上传NUnit的单元测试结果和OpenCover的单元测试覆盖率到SonarQube服务中
  9. 【Hadoop】MapReduce练习:多job关联实现倒排索引
  10. 线程结束,GetExitCodeThread后结束值一直STILL_ACTIVE,259的问题