469,150 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,150 developers. It's quick & easy.

second highest salary use the subquery

Expand|Select|Wrap|Line Numbers
  1. select max(sal) from emp
  2. where sal not in (select max(sal) from emp)
Oct 10 '13 #1
2 9076
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Did you have a question?
Oct 10 '13 #2
Expand|Select|Wrap|Line Numbers
  1. SELECT max(sal) FROM emp WHERE salary < (SELECT max(sal) FROM emp);
  2.  
  3.  
  4. even u can check ur self 
  5. 1 select max(sal) from Emp;
  6.          MAX(SALARY)
  7. --------------------
  8.                 28.3
  9.  
  10. select sal  from Employee order by sal desc
  11.   2  /
  12.  
  13.               SALARY
  14. --------------------
  15.  
  16.                 28.3
  17.                   12
  18.                  5.5
  19.  
  20. SELECT max(sal) FROM emp WHERE salary < (SELECT max(sal) FROM emp);
  21.          MAX(SALARY)
  22. --------------------
  23.                   12
  24.  
  25.  
  26.  


easy way to understand
Oct 11 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Jaspreet | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.