how to get max salary in each department in sql

Solutions on MaxInterview for how to get max salary in each department in sql by the best coders in the world

showing results for - "how to get max salary in each department in sql"
Niko
25 Jan 2018
1SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
2WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
Henry
11 Jan 2019
1SELECT firstname, MAX(salary)
2FROM department d LEFT OUTER JOIN employee e
3ON (d.department_id = e.department_id)
4GROUP BY department_id; 
Eric
30 Oct 2018
1SELECT MAX(SALARY) FROM EMPLOYEES
2UNION
3SELECT MIN(SALARY) FROM EMPLOYEES;
Nicolò
15 Nov 2018
1--Find out the name of top earner in each departments
2--Output has Name, Department name and max salary of the department
3
4SELECT E.FIRST_NAME , D.DEPARTMENT_NAME, E.SALARY
5FROM EMPLOYEES E
6JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
7WHERE SALARY IN(SELECT MAX(E.SALARY)
8FROM EMPLOYEES E
9JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
10GROUP BY DEPARTMENT_NAME);
queries leading to this page
2nd highest salary from employee tableselect 2nd highest salary in mysqlfind 2nd highest salary in sql using rownumsecond largest sql queryget second max salary queryhow many tuples will be retrieved by using following query on given table 3fselect max 28emp sal 29 from employee group by dept no 3b 2ahow to write the inner query to get the max salrymax salary from each department in sqlmysql 3e select min 28salary 29 from user where salary in select salary from user order by salary desc 3bhow to find second max salary in sqlsql find second highest salary2 highest salary in mysqllist the employee with the second height salaryget top salary from each department in sqlsecond maximum salary in sqlsecond largest mysqlmaximum and minimum salary in sqlsql max salary of employeesql query on finding the second highest salary from the employee table calculate 2nd highest salary sqlsql select employee which have the max salary in a given departmenthow to find minimum salary in sqlmax second salary sqlhow to take one max from given states in sql2nd maximum salary in sqlhow to get max value in sql column print second highest salary2nd max salary in sqlsecond largest salary sqlhow to find highest salary in each department in sqlhow to get second highest salary in sqlhow to get the name that has max salary in sqlselect max salary in sql3rd max salary in sqlfinding second highest salary in sqlfind max salary from each departmenthow to get second highest salary in each department in sqlto find second highest salary in sql3rd maximum salary in sqlto find 2nd highest salary in sqltop salary from each department in sqlhow to get salary from another table in sqlhow to get max salary in each department in sqlsecond highest salary in sqlquery to get max salary of employee from each departmentsql query to find second highest salarynth max salary in sqlsecond highest salary queryget max salary from department sqlhow to find max average salary in sqlhow to 3rd maximum salary in sql queryincrease salary who got max salary in sql querysecond highest salary sql serverfind the 2nd highest salary of an emplyeesecend highest salary sql querymax salary in sqlhow to select 2nd highest salary in mysqlwrite a query to figure out the highest employee salary the column is 27salary 27 find second max in sqlget max sum of salary from each department sql second highest salary of an employee sqlselect max salary sqlquery to get 2nd highest salarymax salary employee all info in sql2nd maximum salary in sql serverquery to find and print max salary in sqlhow to find top 3 salary in mysqlselect highest salary in sqlmax 3rd salary sqlsecond highest record in sqlhow to get 3rd max salary in sqlhow to find min average max 28salary in sql 29second highest sqlthird max salary in sqlquery to find maximum salary of employee in sqlfirst max salary in sqlmax salary from each department sqlthird maximum salary in sqlmaximum salary from each department sqlhow to get the highest salary from the employee table in sqlfind second max salary in sqlsql query to display second highest salaryhow to find the second maximum salary in sqlhow to find max and min salary in sqlsecond nd max salary in sqlhow to find the 2nd highest salary in sqlhow to get maximum salary of an employee in sqlget second highest salary in sqlemployee with max salary sqlselect second max salary from sqlsql to find second highest salarysql query get max salary each departmenthow to second highest salary in sqlselect max salary from employee tablesql query to find people with 2 highest salriessql query for 2nd highest salaryselect 2nd highest salary in sqlhow to get a second highest salary in sqlhow to get max from each department in sqlhow to find the second largest number in sqlfind 3rd max and 4th min salary in sql using limitfind second second highest salary in sqlget the max salary in sqlhow to get the second highest salary in sqlsecond highest salary in sql using limit2nd highest salary sql querysql maxfind max salary in each departmentsql query to find 2nd maximum salarywrite a sql query to find max salary and department name from each department how to get max value in sql min max salary in sql2nd highest salary in sqlhighest salary in each department sqlsql sql query to get maximum salary in each departmentgiven a table of employees and their salaries 2c write a query to find employee with the second highet salaryhighest salary from each department in sqlgetting second highest salary in sqlfind second highest salary sqlwrite a sql query to get the second highest salary from the employee table how to calculate second max salary in sqlmax salary in nth sqlthird highest salary in sqlget max salary in sqlselect max salary for all the employeewrite a query to find out minimum salary in each departmentsecond max salary query in sqlfind out max salary between dept 3d 20 and 40mysql 2nd highest salaryhow to get 3 max salary in sqlsql second highest salary querysql query to second highest salaryhow to find second highest salary in sql2nd highest salary in sql using limithow to print max salary in sqlreturn 2nd hightst value in sqlfind minimum salary in sqlfind second largest salary in sqlget max salary from each department in sqlsecond highest in sql2nd min salary in sqlsecond highest salary in sql servermax salary in each department sqlhow to find the second max salary in sqlhow to get max sales in sql from different tableselect second max salary in sqlsql query to find the 2nd highest salaryhow to get 3rd maximum salary in sqlsql max salary by departmentget last max salary from each department sqlfind 3rd max salary in sql using limithow to select 2nd highest salary in sqlfind max salary from each department in sql without maxto get second max employee salary sql query2nd highest salary sqlselect max salary record sqlfind 2nd max salary in sqlsql query to find second maximum salarysql 2nd highest salaryfind the second highest salary in sqlfind second max salary query sql2nd largest salary in sqlsql query to find max salary from each departmentsql query to find second highest salary with out using max 28 29 aggregator operator sql query for max salaryquery for taking second max salary in sqlhow to calculate the second highest salary in sqlsql second highest salary3rd highest salary in sql using limitt sql second highest salarysql sql query to get maximum salary in each department from single table2 max salary in sqlselect second highest salary in sql without using maxnth maximum salary in sqlget the second highest salary in sqlsql queries for employee who have max salaryhow to print details of max salary in sqlsql query for second highest salarygive second highest salary in sqlsecond max salary in sqlsql max salarywrite sql to find max salaryfind second maximum salary in sqlwrite a sql query to print highest salary in 3 consecutive yearshow to get maximum salary in sqlhow to find maximum salary without using max function in sqlprint max salary department wise in sqlsecond max salary in sql serverhow to get 2nd lowest salary in sql3rd max salary sql queryselect max salary from each department in sqlmaximum salary in sqlwrite a sql query to print highest salary in consecutive yearshow to find 2nd max salary in sqlsql return the max valuefind 2nd highest salary in sqlfind the 2nd highest salary in sqlfind max salary and youngest employee in every department sqlfind out the 2nd highest salary in sqlhighest salary in sqlquery for second highest salary in sqlfind maximum salary and 2nd minimum salary in sqlget max salary from each department sqlhighest maximum salary in sqlfind max salary from each department in sqlfind second highest salary in sql using limithow to get max item in sqlwrite sql query to find max salary from each department 28print name and the max salary 29query to find max salarysql query to find max salary of an employeefind second highest salary in sqlgetting maximum salary from each department the tables in each deoartment is differentsecond highest salary sqlmax 3 salary in sqlwrite a query for getting second largest salary from table 22employee 22 captionless imagemax and min salary from employee tablesecond largest salary in sqlhow to get 2nd highest salary in sqlfind the third max salary in sqlselect employee with max salary in each department sqlhow to find top 2 salary in sqlsql get second highest valuefind max salary in sqlthird highest salary in sql using limitsql highest salary in each departmentsql query for 2nd max salary3 max salary in sqlhow to get 2nd max salary in sqlselect 2nd max salary in sqlsecond largest in sqlhow to find the second highest salary in sqlsecond minimum salary sql queries2nd max salary query in sqllist the employees with the heighest salarywrite the query to get the 2nd highest salary in sql how to find max paid salary in sqlsql query to get max salaryselect max 3 salary in sqlget the 2nd highest salary in sqlhighest second salary in sqltop earning employee mysql queryhow to get second highest salary using limit in sqlhow to find top 2 highest salary in sqlmaximum salary in each department sqlsql to find max salary in each departmentsecond minimum salary in sqlwrite an sql query to show the second highest salary from a table second highest salarysecond largest salary sql by maxsecond highest salary codehow to find max salary in sqlmin salary in sqlmax salary by department sqlselect second highest salary in sqlget 2nd highest salary in sqlhow to find 2nd highest salary in sql4 th max salary sql commandwho is the max salary getter for each department in sqlsql query to get second highest salaryfind maximum salary in sqlsql select 2nd max salaryhighest 2nd salary in sqlhow to get max salary in each department in sql