Biggest Single Number
EasyLeetCodeSQL: Aggregation & GROUP BY
Hint and exampleShowHide
First find the values that occur exactly once with HAVING COUNT(*) = 1, then take MAX over that result, which gives NULL when no such value exists.
Example: scores(points)
points
8
8
5
3
SELECT MAX(points) AS points
FROM (
SELECT points
FROM scores
GROUP BY points
HAVING COUNT(*) = 1
) AS singles; -- singles are 5 and 3, so returns 5
More in SQL: Aggregation & GROUP BY
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Classes With at Least 5 Students | LeetCode | Easy | Solve Classes With at Least 5 Students on LeetCode (opens in a new tab) | |||
| 2 | Duplicate Emails | LeetCode | Easy | Solve Duplicate Emails on LeetCode (opens in a new tab) | |||
| 3 | Number of Unique Subjects Taught by Each Teacher | LeetCode | Easy | Solve Number of Unique Subjects Taught by Each Teacher on LeetCode (opens in a new tab) | |||
| 4 | Customer Placing the Largest Number of Orders | LeetCode | Easy | Solve Customer Placing the Largest Number of Orders on LeetCode (opens in a new tab) | |||
| 5 | Biggest Single Number | LeetCode | Easy | Solve Biggest Single Number on LeetCode (opens in a new tab) |