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
  • 145,388
  • 9
  • 31
  • 69
Ravi Ranjan
  • 107
  • 1
  • 1
  • 11

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
  • 145,388
  • 9
  • 31
  • 69