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
LeetCode:595.大的国家的更多相关文章
- LeetCode 595. Big Countries (大的国家)
题目标签: 题目给了我们一个 world table,让我们找出 面积大于3 million square km 或者 人口大于 25 million. 直接用两个条件搜索. Java Solutio ...
- [SQL]LeetCode595. 大的国家 | Big Countries
SQL架构 Create table If Not Exists World (name varchar(), continent varchar(), area int, population in ...
- LeetCode 92 | 大公司常考的面试题,翻转链表当中指定部分
今天是LeetCode专题的第58篇文章,我们一起来看看LeetCode 92题,翻转链表II(Reverse LInked List II). 这题的官方难度是Medium,2451个赞同,145个 ...
- LeetCode.970-强大的整数(Powerful Integers)
这是悦乐书的第367次更新,第395篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第229题(顺位题号是970).给定两个正整数x和y,如果对于某些整数i >= 0 ...
- SQL排名问题,100% leetcode答案大公开!
(首先原谅我最近新番看多了,起了一个中二的名字) 最近在找实习,所以打算系统总结(复习)一下sql中经常遇到问题.不管是刷leetcode还是牛客的sql题,有一个问题总是绕不开的,那就是排名问题.其 ...
- LeetCode 595. Big Countries
There is a table World +-----------------+------------+------------+--------------+---------------+ ...
- [LeetCode] 595. Big Countries_Easy tag: SQL
There is a table World +-----------------+------------+------------+--------------+---------------+ ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
- 【MySQL 基础】MySQ LeetCode
MySQL LeetCode 175. 组合两个表 题目描述 表1: Person +-------------+---------+ | 列名 | 类型 | +-------------+----- ...
随机推荐
- P2341 [HAOI2006]受欢迎的牛(更完)
P2341 [HAOI2006]受欢迎的牛 题解 tarjan 缩点板子题 如果 A 稀饭 B,那就 A 向 B 连边,构造出一个有向图 如果这个有向图里有强连通分量,也就说明这个强连通分量里的所有奶 ...
- 机器学习之Xgboost算法
知识点 """ xgboost:是一种提升算法,串行的决策树 过程: 第一棵树:目标值:1000 ,预测值:950 第二颗树:目标值:1000-950=50(残差作为输入 ...
- 用C#做成的程序如何打包部署,在其他PC机运行
刚刚接触C#,在linux下面做习惯了c和c++,在本机运行OK后,得瑟的去别的机子,居然运行不了,你妹啊,怎么回事,没有.NET Framework,原来和java类似,.NET Framework ...
- for(foo('a') ; foo('b') && (i<2);foo('c'))的执行结果
static boolean foo(char c) { System.out.println(c); return true; } public static void main(String[] ...
- jdk1.8 HashMap & ConcurrentHashMap
JDK1.8逐字逐句带你理解ConcurrentHashMap https://blog.csdn.net/u012403290 JDK1.8理解HashMap https://blog.csdn.n ...
- Linux 的零拷贝技术
目录 文章目录 目录 Linux I/O 缓存背景 零拷贝技术(Zero-Copy) 参考文章 Linux I/O 缓存背景 当请求文件服务器的下载功能时,服务端程序所做的事情是:将服务器磁盘中的文件 ...
- Swagger 介绍
简介Swagger 是最流行的 API 开发工具,它遵循 OpenAPI Specification(OpenAPI 规范,也简称 OAS).Swagger 可以贯穿于整个 API 生态,如 API ...
- Pairs of Numbers
#include<stdio.h> //we have defined the necessary header files here for this problem. //If add ...
- 论文阅读 | TextBugger: Generating Adversarial Text Against Real-world Applications
NDSS https://arxiv.org/abs/1812.05271 摘要中的创新点确实是对抗攻击中值得考虑的点: 1. effective 2. evasive recognized b ...
- 第八周课程总结&实验报告(六)
第八周课程总结 启动多线程售票(上课老师说要加入作业的部分) public class TestDemo { public static void main(StringD args) throws ...