[LeetCode] 619. Biggest Single Number_Easy tag: SQL
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] 619. Biggest Single Number_Easy tag: SQL相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #619 (Div. 2) Ayoub's function
Codeforces Round #619 (Div. 2) 简要题解