SQL · Question 11 · Medium

SQL question 11

Table Employee:
id | name | dept | salary
1 | Asha | HR | 30000
2 | Ravi | IT | 50000
3 | Neha | IT | 60000
4 | Karan | Sales | NULL
5 | Priya | HR | 45000
6 | Vikram | IT | 50000

What value does this query return?

SELECT MAX(salary)
FROM Employee
WHERE salary < (SELECT MAX(salary) FROM Employee);
  1. 60000
  2. 50000
  3. 45000
  4. NULL
Answer and explanation

Answer: B. 50000

Explanation: The inner query gives the highest salary, 60000. The outer query takes the maximum of the salaries below 60000, which is 50000, the second-highest distinct salary.

Previous: Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT… · Next: Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…

Practise sql

Try a fresh set of sql questions with an explanation after every answer, free and without signing up: SQL practice. Or sit a full placement mock test.

More sql questions

More technical & programming practice

Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics · Pseudo-code · C Programming · Java

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge