Check out example codes for "sql find second highest salary employee". It will help you in understanding the concepts better.

Code Example 1

/* sql 2nd highest salary employee */
select sal, ename
from emp
where sal =
        select max(sal) from emp where sal <
            (select max(sal) from emp)
----------------------------------------------- option 2
select *
    select ename, sal, dense_rank() over(order by sal desc) rank
    from emp
where rank =2;

Code Example 2

Both options you find max as a subset and then exclude from main select
sql> SELECT MAX( col ) FROM table
 	WHERE col < ( SELECT MAX( col ) FROM table);
sql> SELECT MAX(col) FROM table 
WHERE col NOT IN (SELECT MAX(col) FROM table);

Code Example 3

/*  Highest salary by Department/Location   */
SELECT e.ename, e.sal, e.deptno, d.loc
FROM emp e
JOIN dept d
ON e.deptno = d.deptno
WHERE e.sal in
  	select max(sal) 
  	from emp 
  	group by deptno

Learn ReactJs, React Native from