Table number
contains many numbers in column num including duplicated ones.
Can you write a SQL query to find the biggest number, which only appears once.
+---+
|num|
+---+
| 8 |
| 8 |
| 3 |
| 3 |
| 1 |
| 4 |
| 5 |
| 6 |
For the sample data above, your query should return the following result:
+---+
|num|
+---+
| 6 |
Note:
If there is no such number, just output null.
Code
SELECT MAX(num) as num FROM (SELECT num FROM number GROUP BY num HAVING COUNT(num) = 1) AS t
# note : have to has AS t
[LeetCode] 619. Biggest Single Number_Easy tag: SQL的更多相关文章
-
[LeetCode] 620. Not Boring Movies_Easy tag: SQL
X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a ...
-
[LeetCode] 176. Second Highest Salary_Easy tag: SQL
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
-
[LeetCode] 196. Delete Duplicate Emails_Easy tag: SQL
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
-
[LeetCode] 584. Find Customer Referee_Easy tag: SQL
Given a table customer holding customers information and the referee. +------+------+-----------+ | ...
-
[LeetCode] 603. Consecutive Available Seats_Easy tag: SQL
Several friends at a cinema ticket office would like to reserve consecutive available seats.Can you ...
-
【一天一道LeetCode】#260. Single Number III
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
-
[LeetCode] 64. Minimum Path Sum_Medium tag: Dynamic Programming
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
-
【LeetCode】137. Single Number II 解题报告(Python)
[LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...
-
[LeetCode] 181. Employees Earning More Than Their Managers_Easy tag: SQL
The Employee table holds all employees including their managers. Every employee has an Id, and there ...
随机推荐
-
PowerShell自动部署IIS站点(Windows Server 2008 R2)
1.功能描述 1. 连接软件源服务器下载.NET Framework 4.0..NET Framework 4.5. 2. 检测并判断当前.NET Framework版本是否小于v4.0,如果小于则进 ...
-
test「Python」流程&;中文
#例1 text='dShArpen骑*在马勒隔壁玩Python时看到一群SB*在逗逼,马上的他马上吓尿了' iftext = '马' for letter in text.decode('u ...
-
查看/修改 Linux 时间和时区
查看/修改Linux时区和时间 一.时区 1. 查看当前时区 date -R 2. 修改设置时区 方法(1) ...
-
Makefile所有内嵌函数
一.文本处理函数以下是GNU make内嵌的文本(字符串)处理函数.1 $(subst FROM,TO,TEXT) 函数名称:字符串替换函数—subst. 函数功能:把字串“TEXT”中的 ...
-
Linux查看所有用户用什么命令
用过Linux系统的人都知道,Linux系统查看用户不是会Windows那样,鼠标右键看我的电脑属性,然后看计算机用户和组即可. 那么Linux操作系统里查看所有用户该怎么办呢?用命令.其实用命令就能 ...
-
类型检测汇总!typeof 和 instanceof 和isArray
, ]; alert(arr instanceof Array);//true 以上老方法判断是否是数组,存在一个问题,就是它只适用于单执行环境(窗口),如果该窗口有其他框架(比如 iframe)则会 ...
-
mysql(5.7)在CentOs7下的安装、配置与应用
和之前版本的mysql有一些不同,现把完整过程记下来,或许对新手来说有用. 本文描述的安装是采用通用的二进制压缩包(linux - Generic)以解压方式安装,相当于绿色安装了. 一.下载通用 ...
-
写入cookie后只显示一次的DIV提示框代码
<script type="text/javascript"> function cookiesave(n, v, mins, dn, path){ if(n) { i ...
-
find文件查找
一.locate locate基于数据库索引来查找文件,数据库在开机时一段时间对更新,不会实时更新,数据库存放在(/var/lib/mlocate/mlocate.db),可以用updatedb来手动 ...
-
1 小时 SQL 极速入门(一)
前几天,我在论坛溜达.看到一个人发帖说 做了6年的企业级开发,总是被互联网行业的人认为没技术含量,不就是CRUD么 先解释下 CRUD 是什么.CRUD 就是我们常说的增删改查(Create,Retr ...