how to get employee having maximum experience in mysql
snippet in sql

Write a SQL query to find the second maximum element from a table.

user8073

SELECT name, MAX(salary) AS salary
  FROM employee
 WHERE salary < (SELECT MAX(salary)
                 FROM employee); 

how to get employee having maximum experience in mysql

user6867

select max(salary), dept_id from employee where salary not in(select max(salary) from employee) group by dept_id;