# Biggest Single Number

• SELECT
num
FROM
number
GROUP BY num
HAVING COUNT(num) = 1
ORDER BY num DESC
LIMIT 1

• @dzirtik Your code cannot pass this test case. Please revise can submit again.
Input:

``````{"headers": {"number": ["num"]}, "rows": {"number": [[8],[1],[8],[3],[4],[3],[1],[4],[5],[5],[6],[6]]}}
``````

Output:

``````{"headers": ["num"], "values": []}
``````

Expected:

``````{"headers": ["num"], "values": [[null]]}
``````

• This post is deleted!

• Do we need to use ifnull() to get null?

• @zhuyidong1120 Feel free to try it out. :)

• I think should consider of the NULL case
SELECT IFNULL((SELECT MAX(num) FROM (SELECT num from num GROUP BY num.num HAVING COUNT(num.num) = 1) AS a), NULL) AS num;

• select max(num)as num from number where num in(
select num from number group by num having count(*)=1);

• ``````SELECT
max(num) num
FROM
(
SELECT
num
FROM
number
GROUP BY
num
HAVING
count(num) = 1
) as numWithOneCount
``````

• select IFNULL(
(
select MAX(num) from
(select num from number
group by num
having count(*)=1) as A
),NULL) as num;

• The `max()` will take care of the `null` condition. no need for `IFNULL`.

`select max(null)` will result in `null`

``````select max(num) as num
from (
select num
from number
group by num
having count(*) = 1
) t
``````

• why it is wrong? I thought max could take care of null condition directly

select max(num) num from number
group by num
having count(*) = 1
order by num desc
limit 1

• ``````SELECT max(num)
FROM (
SELECT
num,
count(*) cnt
FROM numbers
GROUP BY num) t
WHERE t.cnt = 1;
``````

• select max(a.num) as 'num'
from (select num
from number
group by num
having count(num)=1) a;

• select ifnull(
(select n.num
from (select distinct num, count(num) as c
from number
group by num
having c = 1
order by num desc) as n
limit 1), null) as num

• SELECT IFNULL(

(SELECT num
FROM number
GROUP BY 1
HAVING COUNT(*) = 1
ORDER BY num DESC
LIMIT 1)

,NULL) AS num

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.