Biggest Single Number
Problem
Table: MyNumbers
+-------------+------+
| Column Name | Type |
+-------------+------+
| num | int |
+-------------+------+
This table may contain duplicates (In other words, there is no primary key for this table in SQL).
Each row of this table contains an integer.
A single number is a number that appeared only once in the MyNumbers
table.
Find the largest single number. If there is no single number, report null
.
Solution
The problem Biggest Single Number
can be solved using keywords GROUP BY
and HAVING
along with the function MAX
.
Implementation
# Write your MySQL query statement below
SELECT MAX(num) AS num
FROM
(
SELECT num
FROM mynumbers
GROUP BY num
HAVING COUNT(num) = 1
) AS T;