0

I am trying to delete the second highest salary of an employee from a table but I am not able to find out the correct answer.

delete FROM user 
where salary =(select max(salary) from user where salary<(select max(salary) from user));
forpas
  • 160,666
  • 10
  • 38
  • 76
Ravi Ranjan
  • 115
  • 1
  • 1
  • 12

1 Answers1

0

Nest the subquery inside another one:

delete FROM user 
where salary = (select t.sal from (
    select max(salary) sal from user where salary < (select max(salary) from user)
  ) t
);
forpas
  • 160,666
  • 10
  • 38
  • 76