Skip to content
We areTOP 1%

Biggest Single Number

EasyLeetCodeSQL: Aggregation & GROUP BY
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Hint and exampleShow

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

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account