473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 9353
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

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

Similar topics

4
by: Mark | last post by:
good spam subject ;). anyway, i'm alittle stumped. i'm in need of putting together a query that gets the next highest salary ( select max ( sal ) - 1?, from an emp_sal type table. another...
21
by: Jaspreet | last post by:
I was working on some database application and had this small task of getting the second highes marks in a class. I was able to do that using subqueries. Just thinking what is a good way of...
4
by: tathagata | last post by:
I want second highest value in a table without using subquery. please send this answer .It will be very helpfull.
2
by: partha das | last post by:
sir i need a single sql query it may be sub query need to retrive the 5th highest salary from a employee table
6
by: apking | last post by:
please write the programe in c language for this Accept 5 Employee details to find highest salary employe name using for loop and arrays Thanks in advance
1
by: faizan qazi | last post by:
Hello Greetings Guide Me To Find Second Highest Number In Array
2
by: piyushdabomb | last post by:
Hi All, Currently, I have a table with 2 columns COMPONENTID and COMPLETIONDATE COMPONENTID COMPLETIONDATE CBT_HAZCOM 02/26/2007 15:17:00 CBT_HAZCOM 07/31/2007 21:23:00 QS 02/12/2007...
5
by: konaravikumar | last post by:
writing a query to get the second highest value in atable by using select statement
21
by: farzadaumixer | last post by:
hi umm i need help in writing a program in c(or c++) here are the details: i want it to recieve "x" numbers of student id's and the average of the student in their last term and i want it to...
1
by: ygsunilkumar | last post by:
select distinct (a.salary) from employees a where &N = (select count (distinct(b.salary)) from employees b where a.salary <= b.salary); Pls any one explain how the query works, logic behind it.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.