Skip to main content
SQL โ€ข LESSON 94

Subquery with MAX

How can we find employees with the highest salary?

Advancedโฑ 3 Minutesโญ 1070 XP
๐Ÿค” THE QUESTION

How can we find employees with the highest salary?

๐Ÿ’ก WHAT IS IT?

Subqueries with MAX() find records matching the extreme value without hardcoding numerical limits.

๐ŸŽฏ WHAT IS IT USED FOR?

Finding top compensation earners, latest order records, peak metric events.

๐Ÿ’ป EXAMPLE
SELECT name, salary
FROM employees
WHERE salary = (
    SELECT MAX(salary)
    FROM employees
);

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for Subquery with MAX.

  • โœ“ Subquery with MAX
  • โœ“ Peak record matching
  • โœ“ Dynamic filtering
  • โœ“ Exact threshold match