second highest salary

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

showing results for - "second highest salary"
Anthony
18 Oct 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);
Suzanne
05 Sep 2016
1SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
2WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
Judah
29 Jan 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;
Christian
17 Oct 2018
1SELECT MAX(salary) AS SecondHighestSalaryFROM EmployeeWHERE salary != (SELECT MAX(salary) FROM Employee)
queries leading to this page
getting second highest salary in sqlquery to find 2nd largest salary in sqlmax salary in nth sqlsecond largest in sql queryhow to find highest salary in sqlfirst max salary in sqlhow to calculate the second highest salary in sqlsql select only highest valueget second highest record in sqlsql find second max4 th max salary sql commandselect second highest value sqlhow to get third highest salary in sqlhow to 3rd maximum salary in sql queryhow to get the second highest salary in sqlhow to fetch the second highest value from a tablesecond largest salary sqlsql query to find second maximum salary2 highest salary in sqlget second highest salary in mysqlfind second highest number in array in sqlthird maximum salary in sql2nd highest salary in sql using limitfind second highest salary using limit in sqlhow to find second highest salary in sql without using subquerythird highest salaryselect query for second highest salaryhighest salary in sql3rd height salary mysqlhow to find employee who have the second highest salary in sqlemployee with second highest salary sqlfind 2nd last max in sqlsql select second largest valuesecond largest salary sql from employee tablesql second highestwrite a query for getting second largest salary from table 22employee 22 captionless imagehow to get a second highest salary in sqlget highest salary in sqlsecond highest salary employee sqlhow to find second largest salary in sqlsql query find second highest salarysecond max salary from employee tablefind the person with 2nd highest salary sqlto find 2nd highest salary in sqlhow to find highest salary in sqlhow 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 3bquery to find second highest salary of employee3rd maximum salary in sqlsecond max salary in sql queryhow to get 2nd max salary in sqlsecond highest salary in sqlsql find third highest salaryto get second max employee salary sql querysql query to display 2nd highest salaried employee details and may ask for nth highestsecond highest salary in sql using limit2nd largest salary in sqlhow to find 2nd highest salary in sqlfind second second highest salary in sql2nd highest number in sqlsecond largesst salary mysqlsql query to get second highest salary using sub queryfind second maximum salary in sqlfind second highest salary from tablequery to get second max salaryfind second largest salarysecond lowest salary in sqlhow to query second lowest salary from employee table in sqlhow to find top 2 salary in sqlquery second highest salary sqlselect second highest salary from employee table select top 2nd classhow to give find second highest salary in sqlfinding second highest salary in sqlfind the third max salary in sqldisplay the second highest salary employeesecond highest salary practiceselect second highest salary from each department sqlfind second highest salary sqlsecond largest number sql queryget second max value in sqlsql query to select second highest salarysql find second max valuewrite a sql query to print highest salary in consecutive yearshow to get second highest salary using sql what is the query to find second highest salary of employeesql get second highestsql second highest valuehow to get salary from another table in sqlto get second highest salary in sqlsql queries to print second highest salary2nd highest salary sql querysql select 2nd max salarysecond highest sqlfind second highest row sqlsecond highest query in mysqlhow to find third highest salary in sqlwrite a query to retrive 2nd highest salary from a table2nd height salary sqlsql aggregate functions to get second maxsql query to select 2nd highest salaryhow to find second highest salary in sql 3fsql second highest salary of employeehow would you find the second highest salary from the below table mysql 3fselecting second highest salary in sqlselect top 2 salary from employee tablehow select second field of select in sql with max2nd largest element in sql2nd max salary query in sqlselect second highest salary in sql without using maxfind second max in sqlstore the table after joining in sql and then take the second largest element mysql 3e select min 28salary 29 from user where salary in select salary from user order by salary desc 3bsql query to get second highest salaryfirst highest salary in sqlhow to find second highest salary in sql using subqueryfind the employee with the second highest salary using sqlhow to get 3rd maximum salary in sqlget max salary in sqlgiven a table of employees and their salaries 2c write a query to find employee with the second highet salarysecond minimum salary sql queriesselect 2nd max salary in sqlsql query to show the second highest salary from a tablesql query for 2nd max salarysecons hiest salary in sqlget the 2nd highest salary in sqlhow to get 3rd max salary in sqlsql query to display second highest salary for every employeeselect second highest salarysql query to get second highest salary using rownumhow to find the second highest salary in sqlsql select 2nd highest valueselect second highest salary in sqlsql select second highestselect the second highest salary in sql querysecond max salary query in sqlprint second highest salarysql query to find people with 2 highest salriessecend highest salary sql queryhow to get 2nd max value in sqlhow to give find second highest salary in sql as second highest salaryquery for taking second max salary in sqlmost efficient query to second largest valueprint name of second highest salary in sqlwrite a sql query to find 2nd maximum salary3 max salary in sqlselect 2nd highest salary in mysqlhow to get second max in sqlmax function in sql to find second highestsecond highest salary codefetch second highest salary sqlsql query for find second highest salarysecond max salary using group by havingmin max salary in sqlselect second highest sqlhow 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 mysqlget second highest salary today in sqlfind out the 2nd highest salary in sqlget second highest salary in sqlhow to get 2nd highest salary in sqlhow to second highest salary in sqlhow to find the second biggest salary sqlfind 3rd max salary in sql using limitaccess sql select max datehow to find the third highest salary in sqlhow to find second highest salary in sql using limitsql select second maxgive second highest salary in sqlfind 2nd max salary in sqlfind second largest salary in sqlhow to calculate second max salary in sqlhow to find the second maximum salary in sqlhow to get second highest salary in sql serverhow to select the second highest value in sqlhow to get second highest salary using limit in sqlsql problem to find nth highest salaryhow to pull 2nd maximum record sqlsecond highest salary sql serverfind the 2nd highest salary of an emplyeehow 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 find 2nd highest number in sql second highest salary of an employee sqlsecound highest value in sql3rd max salary sql queryquery to get 2nd highest salaryselect second max salary in sqlthird highest salary in sql using limithow to select 2nd highest salary in sqlshallow last second salary in mysqlfind second highest salarysql get lowest valuewrite a sql query to find the second highest salary from employees table highest second salary in sql using limitw3 school 2nd largest salary querymaximum salary in sqlfinding top2 nd highest salary in sql2nd maximum salary in sql serverfind the second highest salary in sql2nd highest salary from employee tableget the second highest salary in sql servermax 3rd salary sql3rd highest salary in sql using limitquery to select the emp of max salarysecond highets value sqlwrite the sql command to fetch 2nd highest salary from the employee table select max 28salary 29 from employee where salary not in 28 select max 28salary 29 from employee 29 3bsql second highest salarywithot aggregatems sql server salary doublesql select the second highest countsql second highest salarywrite a sql query to get the second highest salary from the employee table write a query to display second max salary of an employee 3fsecond highest salary database queryselect 2nd highest salary in sqlsql query to find the employee with the second highest salaryselect second max id from table sqlhow to find minimum salary in sqlhow to find top 2 highest salary in sqlhow to get max salary in each department in sqlhighest second salary in sqlwrite an sql query to show the second highest salary from a table 2nd maximum salary in sql emp tanlequery for second highest salary in sqlhow to get 2 highest salary using sqlsql get second maxt sql second highest salarycoderbyte mysql challenge mysql challenge 2c your query should return the informatioi for the employee with the third highest salary mysql get second highestsql query how to find second highest salarysql query for max salarysql query to find 2nd lowest salarysql query to find second highest salary with out using max 28 29 aggregator operator find the 2nd highest salary in sqlget 2nd highest salary from employee tablefind second highest salary in sql without subqueryselect max salary for all the employeesql second highest using fetchhow to find second highest salary in sql without using corelated querysql command to find second highest salarymysql get max salaryselect seceond higest query languagesecond largest sql queryget second max from sql tablehow to find 2nd max salary in sqlget 3rd highest salary in sqlhow to find max salary in sql using subquerysql find second highestsql get second highest valuewrite sql query to get the second highest salary among all employeesselect max salary from employee tablefind top 2 salary sqlfind second max salary in sqlwrite the query for finding the second highest salarywrite the query to get the 2nd highest salary in sql calculate second highest salary in sqlhow to get the highest salary from the employee table in sqlsecond highest from sqlcalculate 2nd highest salary sqlhow to find the second highest number in sqlselect top 2nd highest salary for sql2nd highest salary query in sql2 max salary in sqlsecond max salary using havingsecond max salary in sql serverget the last thee max salaried person from table via sql second largest salary in sqlsql find second highest salaryhighest salary in sqfind the second highest salary among the given table 28sql 29second highest salary in mysqlsecond maximum sql querylist the employee with the second height salarymax 3 salary in sqlsecond highest salary sql queryhow to find second max salary in sqlfind second max value in sqlsql get third highest salarygroup by in sql write the query for finding the second highest salarygroup by in sql 2c write the query for finding the second highest salaryfind highest salary in each department sql2nd largest value in mysqlhow to get 2nd lowest salary in sqlget the second max value sql to find second highest salary in sqlmin salary in sqlhow to find the second max salary in sqlfind 2nd highest salary in sqlfind second highest salary in sqlsql select second highest valuefind the 2nd largest salary in sqlsql select second highest salarythird max salary in sqlhow to print highest salary in sqlfinding second highest salarynon correlated subquery to find second hoghest salary with examplescount second highest marks in sql querthow to find top 3 salary in mysqlsql query on finding the second highest salary from the employee table in 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 visionidsecond highest salary sqlsql query to find the second highest salary of an employeeselect 2nd highest salary from employee table in sqlsql query to find the second highest salaryhow to find maximum salary without using max function in sqltop 2 salary in sql2nd max salary in sqltop earning employee mysql queryselect employee with second highest salary sqldefine the second cte 2c itsalary 2c with the fields id and salary csdnto second last highest salary in sqlsecond maximum record from sqlhow to fetch second highest number from a dataabasesecond highest salary salary tablesecond highest salary in mysql emp table queryget second max salary queryhow to find second max value in sqlsecond max in sqlwrite a sql query to get the second highest salary from the employee tablemultiple second highest sqlget the second highest salary in sqlget 2nd highest salary in sqlsecond largest in sqlfind second max salary in sql using limitfind third highest salary in sql serverselect top 2 salary in sqlfind second max salary query sqlsql query to find second highest salaryget second highest value sqlsql query for getting second highest salaryhow to select third highest value in sqlfind third highest salary in sqlselect max salary using top sqlquery for second highest salaryquery to find maximum salary of employee in sqlsecond highest in sqlhow to find the 2nd highest salary in sqlsql query to return second highest salarywrite a sql query for second highest salaryselect second highest in sqlselect max salary sqlwrite a sql query to print highest salary in 3 consecutive yearsslary table my sqlmax 2nd salary in sql querywith the highest salaries sqlselect second highest value sqlhow to get second highest salary in sqlsql second max2nd highest salary in sqlsql query to find third highest salaryprint second and third highest salary in sqlsecond highest no in table in sqlget third highest salary in sqlfind the second max in sqlhow to get highest salary in sqlsecond maximum salary in sqlsql query for 2nd highest salarysql query to find details of highest salarywrite a query to figure out the highest employee salary the column is 27salary 27 2nd min salary in sqlsecond maximum in sqlsecond nd max salary in sqlwrite a query to find the second max salarygive me a query to find out the second largest compensation in an organization 3fselect max 3 salary in sqlprint second highest salary in sqlhow to 2nd highest salary in sqlfind second largest salary sqlhow to select second highest value in sqlhow to set second largest salary in sqlhow to get second highest salary in sql for all employeesecond highest value in sqlsecond largest salary sql by maxselecting second max value sql2nd max salary in mysqlselect max salary record sqlselect second highest salary sqlfind the second largest salary in sql queryhow to find 2nd largest salary in sqlsql how to get 2nd highest salarysql command for 2nd highest salaryselect highest salary in sqlselect the 2nd maximum sqlsalary in my sqllist the employees with the heighest salarysql query to find the 2nd highest salarynon correlated subquery formula to find second hoghest salary with examples2nd max element sql querysecond highest salary also get other columns in sqlsecond height salary sqlsecond minimum salary in sqlsecond highest record in sqlhow to print 2nd highest salary in sqlselect name from emp where salary 3e 28select max 28salary 29 from emp where salary 3c 28select max 28salary 29 from emp 29 29 3bfind 2nd highest salary in sql using rownumgive me a query to find out the second largest compensation in an organization2nd highest salary from table order by second highest salary in sqlnth maximum salary in sqlselect 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 3fselect highest salary in sql serversql to find second highest salaryquery to select employee with max salarysql get the second highest valuehow to get second highest salary in each department in sqlsecond max salary in sqlhow to get the 2nd highest salary in sqlget second highest salaryselect second highest salary in sql queryhow to find the second largest number in sqlmysql second highest salarysecond highest salaryselect second max salary from sqlfind second highest salary in sql using limitthird highest salary in sqlsecond highest salary querysql find second highest salary employeefind the second largest value in column of a tablesql server 2nd highest salaryhow to select 2nd highest value in sqlselect nth highest salary in sqlhow to find second highest salary in sqlreturn 2nd hightst value in sqlsql 2nd highest salaryhow to select 2nd highest salary in mysqlfind the third highest salary in sqlsecond largest mysqlmax salary in sqlfind second max sqlsecond highest salary in sql serversecond max sqlsql query to find 2nd maximum salary3rd max salary in sql2nd highest salaryget 2nd hieghest salary of employee using sql querysql get time by second highest salarymysql 2nd highest salarysql 2bhighest salarywhere salary 3d max 28salary 29 sqlselect second max value in sqlsql query for second highest salaryhighest 2nd salary in sqlfind maximum salary in sqlget second max record in sql serversecond highest salary statementshow to find max salary in sqlsql second highest salary queryselect max salary in sqlhow to find max paid salary in sql2nd maximum salary in sqlhow to get the second highest salary in sql 3f2 highest salary in mysqlsecond height salary mysqlget second highest salary from query sqlselceting second highest salaryhow to write the inner query to get the max salrywrite an sql query to show the second highest salary from a tablesql server second highest salaryquery to get second highest salarynth max salary in sqlsql query to find third highest salary of employee2nd highest salary in sql 5csql query to display second highest salarysql query to find employee who has second highest salary2nd highest salary sqlhow to find highest average in sqlsql query to second highest salarysql query to query nth largest salarysecond highest salary