Interview Questions/SQL/Find the Largest Single Number

Find the Largest Single Number

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Find the Largest Single Number

You are given a table MyNumbers that contains integers, possibly with duplicates. A single number is defined as a number that appears exactly once in the table. Write a SQL query to find the largest single number. If there are no single numbers, return null.

Examples

Example 1

Numbers appearing exactly once: 1, 4, 5, 6. The largest among them is 6.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql