second max salary in sql

Solutions on MaxInterview for second max salary in sql by the best coders in the world

showing results for - "second max salary in sql"
Lara
23 Jan 2019
1Both options you find max as a subset and then exclude from main select
2sql> SELECT MAX( col ) FROM table
3 	WHERE col < ( SELECT MAX( col ) FROM table);
4sql> SELECT MAX(col) FROM table 
5WHERE col NOT IN (SELECT MAX(col) FROM table);
Magdalena
04 Mar 2020
1SELECT MAX(salary), MIN(salary) FROM employees;
Emiliano
04 Nov 2016
1SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
2WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
Jessica
12 Mar 2018
1/* sql 2nd highest salary employee */
2select sal, ename
3from emp
4where sal =
5    (
6        select max(sal) from emp where sal <
7            (select max(sal) from emp)
8    )
9----------------------------------------------- option 2
10select *
11from 
12(
13    select ename, sal, dense_rank() over(order by sal desc) rank
14    from emp
15)
16where rank =2;
Harley
11 Jan 2018
1SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
2WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
3
4
5OR
6
7Here is the solution for nth highest
8salary from employees table 
9
10SELECT FIRST_NAME , SALARY FROM 
11(SELECT FIRST_NAME, SALARY, DENSE_RANK() OVER
12(ORDER BY SALARY DESC) AS SALARY_RANK
13FROM EMPLOYEES)
14WHERE SALARY_RANK = n; 
Giorgio
21 Jul 2017
1SELECT firstname, MAX(salary)
2FROM department d LEFT OUTER JOIN employee e
3ON (d.department_id = e.department_id)
4GROUP BY department_id; 
queries leading to this page
2nd highest salary from employee tablefind 2nd highest salary in sql using rownummysql get second highestsql query to find details of highest salaryhow to print highest salary in sqlhow to write the inner query to get the max salrymysql 3e select min 28salary 29 from user where salary in select salary from user order by salary desc 3bsql query find second highest salaryhow to find second max salary in sqlaccess sql select max datesecond highets value sqlhow to find second highest salary in sql using subqueryhow to find minimum salary in sqlhow to get second highest salary using sql sql second highest value2nd max salary in sqlsql select second largest valuesql second highestget the 3rd highest salary sqlsql get time by second highest salarymysql query to get second highest salarysecond highest salary in mysqlhow to get max salary in each department in sqlsecond highest salary querycount max salary in sqlnth max salary in sqlsql get second maxsecond max salary in sql queryhow to find the third highest salary in sqlmax salary in sqlfind 4th highest salary in sqlselect max salary sql second highest salary of an employee sqlhow to select the second highest value in sqlget second highest salary in mysqlquery to get 2nd highest salarystore the table after joining in sql and then take the second largest element sql select the second highest countsecond highest record in sqlselect second max id from table sqlfind the second max in sqlwhat is the query to find second highest salary of employeemost efficient query to second largest valuesql find third highest salaryhow to find last 2nd highest salary in sqlfind second max salary in sqlsecond highest salary also get other columns in sqlw3 school 2nd largest salary queryhow to find max and min salary in sqlsql query for second largest salarysql query to find people with 2 highest salriessql query for 2nd highest salarysql aggregate functions to get second maxfind 3rd max and 4th min salary in sql using limitselect the 2nd maximum sqlsql command for 2nd highest salarysecond highest salary in sql using limit2nd highest salary sql queryhow to get second max in sqlfind the 2nd max salary in sqlgiven a table of employees and their salaries 2c write a query to find employee with the second highet salaryfinding second highest salarysql problem to find nth highest salaryhow to select 3rd highest salary in sqlsql select second highestmax salary in nth sqlwrite a sql query to get the second highest salary from employee tableselect max salary for all the employeeslary table my sqlwrite a query to find out minimum salary in each departmentgroup by in sql 2c write the query for finding the second highest salarysecond highest from sqlsql second highest salary querymultiple second highest sqlwhat is the query for second highest salary in sql2nd highest salary query in sqlget the last thee max salaried person from table via sql how to find second max value in sqlsql query to find the 2nd highest salarywrite the sql command to fetch 2nd highest salary from the employee table query to find second highest salary of employeesecond max salary from employee tablesql query to find second maximum salaryselect second highest salary sqlsql query to find second highest salary with out using max 28 29 aggregator operator print name of second highest salary in sqlsql query for max salaryhow to select third highest value in sqlsql select second maxhow to calculate the second highest salary in sqlget the second highest salary in sqlnth maximum salary in sqlhow to get the 2nd highest salary in sqlsql max salaryselect top 2nd classwrite sql query to get the second highest salary among all employeeswrite a sql query to print highest salary in 3 consecutive yearshow to get maximum salary in sqlsql query how to find second highest salaryhow to get 2nd lowest salary in sql3rd max salary sql queryprint second and third highest salary in sqlwrite a sql query to print highest salary in consecutive yearsthird highest salary sqlget 3rd highest salary in sqlcount second highest marks in sql querthow to add employee name and department name in this query select 28select max 28salary 29 from employee 29 max salary 2c 28select max 28salary 29 from employee where salary not in 28select max 28salary 29 from employee 29 29 as 2nd max salary 3bwrite a sql query for second highest salaryget 2nd highest salary from employee tablehow to find second highest salary in sql without using corelated queryfind third highest salary in sql serverhow to find the second highest number in sqlmysql get max salaryhow to get 3rd highest salary in sqlwrite a query to retrive 2nd highest salary from a tablesql find second max value4th highest salary in sqlhighest salary in sqlquery for second highest salary in sqlhow to find the 3rd highest salary in sqlget second highest salarysql get third highest salaryhow to get 2 highest salary using sqlsecond largest number sql querynth highest salary sql queryselect name from emp where salary 3e 28select max 28salary 29 from emp where salary 3c 28select max 28salary 29 from emp 29 29 3bfind the third highest salary in sqllist the employees with the heighest salarysecond highest salary sql queryselect 2nd max salary in sqlsql qury to get the second highest salaryhow to find max paid salary in sqlfind top 2 salary sqltop earning employee mysql queryhighest second salary in sqlsecond nth highest salary in sqlsql query to find employee who has second highest salaryhow to get second highest salary using limit in sqlshallow last second salary in mysqlwrite an sql query to show the second highest salary from a table write a sql query to get the second highest salary from the employee tableget 2nd highest salary in sql4 th max salary sql commandselect max 28salary 29 as salary from employee where salary 3c 28select max 28salary 29 from employee 29 3b what is the output of this query 3fsql query to find third highest salary of employeeto second last highest salary in sqlsql query to display second highest salary for every employeemysql second highest salarysalary in my sqlhow would you find the second highest salary from the below table mysql 3fhow select second field of select in sql with maxsecond height salary sqlgive me a query to find out the second largest compensation in an organization 3fsql qurey to find max salarysecond maximum salary in sqlwrite an sql query to show the second highest salary from a tableget highest salary in sqlmaximum and minimum salary in sqlsql query on finding the second highest salary from the employee table calculate 2nd highest salary sql2nd largest element in sql2nd maximum salary in sqlhow to get 2nd max value in sqlsql query to get second highest salary using sub querysecond max salary using havingselect second highest value sqlhow to get second highest salary in sqlhow to get the name that has max salary in sqlget second max from sql tablesql query to select 2nd highest salaryselect max salary in sqlselect top 2 salary in sqlto find second highest salary in sqlfind the employee with the second highest salary using sqlselect second highest value sql2nd and 3rd highest salary in sqlto find 2nd highest salary in sqlnth highest salary in sql using cteselect second highest in sqlselect top 2nd highest salary for sqlsql query to find second highest salary2nd height salary sqlfind the second largest value in column of a tablehow to find max average salary in sqlthird highest or second highest salary queryfind second highest number in array in sqlsecend highest salary sql querywrite a query to figure out the highest employee salary the column is 27salary 27 get third highest salary in sqlsecond highest salary in sql using maxfind second max sqlhow to find top 3 salary in mysqlnth highest salary in sqlfind second max value in sqlsecond highest sql2 minimum and maximum salary in sqlselect second highest sqlthird max salary in sqlhow do you 2nd highest salary in sqlquery to find maximum salary of employee in sqlfirst max salary in sqlfind second highest salary using limit in sqlsql query to find second highest salary of employeehow to get the highest salary from the employee table in sqlthird highest salary in sql using rownumhow to find the second biggest salary sqlhow to print 2nd highest salary in sqlhow to get third highest salary in sqlselect second max salary from sqlquery to find 2nd largest salary in sqlhow to second highest salary in sqlselect max salary from employee table3rd height salary mysqlselect 2nd highest salary in sqlhow to find the second largest number in sqlfourth highest salary in sqlmax function in sql to find second highesthow to get the second highest salary in sqlsql query to find the second highest salary of an employeesql query to find 2nd highest salarysql print max and min salarysql query to find 2nd lowest salary2nd highest salary in sqlgroup by in sql write the query for finding the second highest salaryq how to get the second highest salary using sql 3fsecond highest salary database querygetting second highest salary in sqlselect second highest salary from each department sqlhow to calculate second max salary in sqlsecond highest salary in sql querythird highest salary in sqlget max salary in sqlsecond max salary query in sqlhow to find the tenth highest salary in sqlsql select 2nd highest valuefind minimum salary in sqlsecond highest in sqlget second highest value sqlget third highest salary using max 28 29 in sqlselect second highest salary from employee table 2nd highest salary sqlselect max salary record sqlfind 2nd max salary in sqlquery to get second highest salarysql 2nd highest salaryfind the second highest salary in sqlfind second max salary query sqlsql second highest salary2 max salary in sqlselect second highest salary in sql without using maxhow to print details of max salary in sql2nd maximum salary in sql emp tanlewrite sql to find max salaryselect employee with second highest salary sqlsecond max salary in sql serversql 2bhighest salaryhow to find 2nd max salary in sqlfind 2nd highest salary in sqlhow to give find second highest salary in sql as second highest salaryselect second max value in sqlhow to max salary in a table sqlfind max salary from each department in sqlwhere salary 3d max 28salary 29 sqlquery to find max salaryhow to find employee who have the second highest salary in sqlfind second highest salary in sqlsql get lowest valuesql get second highestsecond largest salary in sqlget second highest salary in sql using ctethird highest salary in sql using limitselect the second highest salary in sql querysecond largest in sqlwrite the query to get the 2nd highest salary in sql how to find the second highest salary in sql2 highest salary in sqlget the 2nd highest salary in sqlhow to find top 2 highest salary in sqlfirst highest salary in sqlsecond highest query in mysqlsecond largest salary sql by maxsecond highest salary codesecound highest value in sqlhow to find max salary in sqlsecond highest salary from salary colun sql commandfinding the third highest salary in sqlselect second highest salary in sqlsql query to get second highest salarysql second highest salary of employeesql select 2nd max salarymin average max 28salary in sql 29how to select 2nd highest salary in mysqlwrite a query to display second max salary of an employee 3fsql queries to print second highest salarysql highest salaryselect highest salary from table in sqlselect 2nd highest salary in mysqldefine the second cte 2c itsalary 2c with the fields id and salary csdnget second max salary queryhow to find second highest salary in sql using limitsql query for getting second highest salaryhow many tuples will be retrieved by using following query on given table 3fselect max 28emp sal 29 from employee group by dept no 3b 2asql find second highest salarysql third highest salaryselect highest salary in sql serversecond largest mysqlsql query to find out highest salary from thesql how to get 2nd highest salarymax second salary sqlget second highest salary from query sqldisplay the second highest salary employeeget second highest salary of a particular department sqlsecond max in sqlprint second highest salarysecond largest salary sqlwrite a sql query to find 2nd maximum salary3rd max salary in sqlfinding second highest salary in sqlhow to find third highest salary in sql2nd max salary in mysql3rd maximum salary in sqlfinding top2 nd highest salary in sqlhow to get salary from another table in sqlselect top 2 salary from employee tableget max salary from department sqlselect query for second highest salary2nd max element sql queryselecting second highest salary in sql2nd highest number in sql2nd maximum salary in sql serversecond highest salary sql using maxfind second largest salary sqlmax 3rd salary sqlquery to get second max salaryhow to get 3rd max salary in sqlhow to find min average max 28salary in sql 292nd highest salary from table how to 2nd highest salary in sqlhow to give find second highest salary in sqlhighest second salary in sql using limitsql find second maxfind the person with 2nd highest salary sqlthird maximum salary in sqlsql second highest salarywithot aggregatesql query to display second highest salaryhow to find the second maximum salary in sqlget second highest salary in sqlsecond maximum in sqlselect second highest salary in sql with other datasql command to find second highest salarysql select second highest salaryselect max 28salary 29 from employee where salary not in 28 select max 28salary 29 from employee 29 3bfind second second highest salary in sqlwrite a query to find the second max salarywrite a sql query to find the second highest salary from employees table get the max salary in sqln highest salary in sqlfind the second highest salary among the given table 28sql 29find second max salary in sql using limitsecond highest no in table in sqlsql second highest using fetchhow to add employee name and department name in this query select 28select max 28salary 29 from employee 29 max salary 2c 28select max 28salary 29 from employee where salary not in 28select max 28salary 29 from employee 29 29 as 2nd max salary 3b in mysqlgive me a query to find out the second largest compensation in an organizationsql select only highest valuehow to find 2nd largest salary in sqlmysql 2nd highest salarysql 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 second largest salary in sqlhow to find highest average in sqlsql query second highest salarysecond lowest salary in sqlsecond highest salary in sql serverhow to find the second max salary in sqlselect second max salary in sqlhow to get 3rd maximum salary in sqlhow to select 2nd highest value in sqlfind 3rd max salary in sql using limithow to get 2nd and rd highest salary in sqlget second max record in sql serverfind max salary from each department in sql without maxlowest salary in sqltop 2nd highest salary in sql2nd largest salary in sqlselecting second max value sqlfind third highest salary in sqlsql query for second highest salaryselect 2nd highest salary from employee table in sqlhow to set second largest salary in sqlsecond max salary in sqlsecond height salary mysqlfind second maximum salary in sqlto get second highest salary in sqlemployee with second highest salary sqlsql select second highest valuemaximum salary in sqlnth highest salary in sql serverorder by second highest salary in sqlfind the 2nd highest salary in sqlhow to get the maximum and minimum salary of employees in sqlnon correlated subquery to find second hoghest salary with examplesfind maximum salary and 2nd minimum salary in sqlsql query to find the second highest salarysql second maxhighest maximum salary in sqlhow to find highest salary in sqlsql server 2nd highest salaryselect max salary using top sqlgetting 4th highest salary in sqlsql query to query nth largest salaryhow to get max of salary in sqlmax 3 salary in sqlhow to find second largest salary in sqlsql query to find the employee with the second highest salarymax and min salary from employee tablefind the third max salary in sqlhow to get 2nd highest salary in sqlselect the highest salary in sql querysql query for 2nd max salarymax salary with name in sqlfind 2nd last max in sqlget 2nd hieghest salary of employee using sql querysecond minimum salary sql queries2nd max salary query in sqlhow to highest salary in sqlsql query to get max salarysecond highest salary in mysql emp table queryselect max 3 salary in sqlsecond highest salary insqlsecond max sqlhow to find the 2nd highest salary in sql serversql to find max salary in each departmentsecond minimum salary in sqlsecond maximum record from sql2nd largest value in mysqlsecons hiest salary in sqlsql query highest salaryget second most highest salary sqlhighest 2nd salary in sqlhow to select second highest value in sqlhighest salary in sqsecond largesst salary mysqlsecond highest salary employee sql2nd highest salary in each department sqlsecond largest sql query14th highest salary sqlwith the highest salaries sqlsql server second highest salaryselect nth highest salary in sql2 highest salary in mysqlsql query to select second highest salarylist the employee with the second height salaryhow to find second highest salary in sql 3ffind out third highest salary in sqlget second max value in sqlfind 3rd highest salary in sqlsql query to find third highest salaryhow to query second lowest salary from employee table in sqlget second highest salary today in sqlhow to get second highest salary in each department in sqlsecond largest in sql querysecond highest salary in sqlhow to find 2nd highest number in sqlsql query to show the second highest salary from a tablehow to 3rd maximum salary in sql querysecond highest salary sql serverfind the 2nd highest salary of an emplyeefind second max in sqlhow to get highest salary in sqlcoderbyte mysql challenge mysql challenge 2c your query should return the informatioi for the employee with the third highest salary query for second highest salaryquery to select employee with max salaryquery to find and print max salary in sql3rd highest salary in sqlselect highest salary in sqlfind second largest salaryselect second highest salary in sql queryhow to fetch the second highest value from a tablehow to get the second highest salary in sql 3ffind the 2nd largest salary in sqltop 2 salary in sqlhow to find max salary in sql from rowsecond nd max salary in sqlhow to find the 2nd highest salary in sqlsql to find second highest salaryfind highest salary in each department sqlhow to get a second highest salary in sqlhighest nth salary in sqlquery second highest salary sqlsql query to find 2nd maximum salarymin max salary in sqlhow to find highest salary in sqlsql query to display 2nd highest salaried employee details and may ask for nth highestemployee second highest salary in sqlhow to display second highest salary in sqlfind second highest salary sqlwrite a sql query to get the second highest salary from the employee table how to fetch second highest number from a dataabasems sql server salary doublenon correlated subquery formula to find second hoghest salary with examplesquery to select the emp of max salaryhow to get second highest salary in sql serverhow to pull 2nd maximum record sqlfinding max salary sqlfind the second largest salary in sql query2nd min salary in sqlselect seceond higest query languagesql query to get second highest salary using rownumwrite the query for finding the second highest salarymax of salary in sqlhow to select 2nd highest salary in sqlsql find second highest salary employeesql query to find out the second highest salary to get second max employee salary sql queryget the second highest salary in sql serversecond max salary using group by havingcalculate second highest salary in sqlquery for taking second max salary in sqlsecond highest value in sqlhow to get second highest salary in sql for all employeemax 2nd salary in sql query3rd highest salary in sql using limitt sql second highest salarysql query to return second highest salarygive second highest salary in sqlfind second highest row sqlsql find second highesthow to find maximum salary without using max function in sqlget second highest record in sqlsql get the second highest valuefetch second highest salary sqlget the second max value sql 2nd highest salary in sql 5csql query for find second highest salaryfind out the 2nd highest salary in sqlfind the nth highest salary in sqlhow to find second highest salary in sql without using subqueryin this mysql challenge 2c your query should return the informatioi for the employee with the third highest salary write a query that will find this employee and return that row 2c but then replace the di visionidfind second highest salary in sql using limithow to get 4th highest salary in sqlsecond highest salary sqlsql to find third highest salarygetting 3rd highest salary sqlwrite a query for getting second largest salary from table 22employee 22 captionless image3rd highest salary in sql using maxhow to find top 2 salary in sqlsql get second highest valuefind max salary in sqltop min salary in sql from max 5 salary3 max salary in sqlhow to get 2nd max salary in sqlnth highest salary sqlsecond largest salary sql from employee tableselect the 5 th highest salary in sqlprint second highest salary in sqlhow to find max salary in sql using subquerysecond highest salaryhow to find 3rd highest salary oehr in sqlsql query to find the second highest salary of employee 3ffind second highest salary in sql without subquerymin salary in sqlhow to find 2nd highest salary in sqlsecond maximum sql queryfind maximum salary in sqlsecond max salary in sql