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的更多相关文章

  1. [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 ...

  2. [LeetCode] 176. Second Highest Salary_Easy tag: SQL

    Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...

  3. [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 ...

  4. [LeetCode] 584. Find Customer Referee_Easy tag: SQL

    Given a table customer holding customers information and the referee. +------+------+-----------+ | ...

  5. [LeetCode] 603. Consecutive Available Seats_Easy tag: SQL

    Several friends at a cinema ticket office would like to reserve consecutive available seats.Can you ...

  6. 【一天一道LeetCode】#260. Single Number III

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  7. [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 ...

  8. 【LeetCode】137. Single Number II 解题报告(Python)

    [LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...

  9. [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 ...

随机推荐

  1. 导航+左侧菜单+tab切换模板

    <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Conten ...

  2. maven项目启动报错:SLF4J: Class path contains multiple SLF4J bindings.

    SringBoot的Application启动报错: SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding ...

  3. 洛谷P1908 逆序对【递归】

    题目:https://www.luogu.org/problemnew/show/P1908 题意:给定一个数组,求逆序对个数. 思路: 是一个很经典的题目了.通过归并排序可以求逆序对个数. 现在有一 ...

  4. POJ 3635 - Full Tank? - [最短路变形][手写二叉堆优化Dijkstra][配对堆优化Dijkstra]

    题目链接:http://poj.org/problem?id=3635 题意题解等均参考:POJ 3635 - Full Tank? - [最短路变形][优先队列优化Dijkstra]. 一些口胡: ...

  5. HDU 5985/nowcoder 207D - Lucky Coins - [概率题]

    题目链接:https://www.nowcoder.com/acm/contest/207/D 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5985 ...

  6. Hive中的窗口函数

    简介 本文主要介绍hive中的窗口函数.hive中的窗口函数和sql中的窗口函数相类似,都是用来做一些数据分析类的工作,一般用于olap分析 概念 我们都知道在sql中有一类函数叫做聚合函数,例如su ...

  7. iOS开发ffmpeg SDK 编译和集成

    FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.它提供了录制.转换以及流化音视频的完整解决方案.同时,FFmpeg是一套跨平台的方案,所以我们可以在iOS开发中使 ...

  8. PHP之获取终端用户IP

    // function get_real_ip() { $ip=false; $clientip = "clientip"; $xrealip = "xrealip&qu ...

  9. MySQ数据表设计

    数据表概念 数据表是数据库中的基本对象元素,以记录(行)和字段(列)组成的二维结构用于存储数据.数据表由表结构和表内容两部分组成,先建立表结构,然后才能输入数据.数据表结构设计主要包括字段名称.字段类 ...

  10. Java如何对List集合的操作方法(二)

    4.list中查看(判断)元素的索引: 注意:.indexOf(): 和  lastIndexOf()的不同:   ///*************************************** ...