Skip to main content
SQL • LESSON 94

Subquery with MAX

How can we find employees with the highest salary?

Advanced3 Minutes1070 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