Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to find the second highest salary from emp table?

Answers were Sorted based on User's Feedback



how to find the second highest salary from emp table?..

Answer / shrikant

You can find nth max salary

change "limit 0,n" where n = 1,2,3...

select b.sal from (select a.sal from (select distinct sal
from emp order by sal desc) a limit 0,n) b order by sal asc
limit 0,1;

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / shivdas suryawanshi

select salary from emp where salary=(select max(salary)
from emp where salary < (selct max(salary) from emp));

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / nirjesh pandey

select salary from employee order by salary DESC LIMIT(1,1)

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / nirjesh pandey

select salary from employee order by salary DESC LIMIT(1,1);

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / masthan

select *from emp where sal<selct *from emp where<select *from emp

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / hridayeshwar rao

select max(age) from yd where age<(select max(age) from HK) ; /// True two table Highest

SELECT * FROM HK E1 WHERE 1 =(SELECT COUNT(DISTINCT age) FROM HK E2 WHERE E1.age < E2.age); ///Second Hightest age RT single table

select age from hk e1 where (3-1) = (select count(distinct (e2.age)) from yd e2 where e2.age>e1.age);//// same True Second Hight age RT two table

select max(age) from YD where age not in (select max(age) from YD); //second hight age in single table

Suppose that salery=age

Thanks !!!

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / abhijeet banarse

Select level,Max(sal) from emp1
Where level=&level connect by prior sal>sal
group by level;
Enter the level No=2 (Here enter 2 manually)

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / moharaj m

select max(salary) from emp where salary < (select max
(salary) from emp)

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / rajesh chauhan

sql>select max(salary)from(select salary from employee where
salary not in(select max(salary)from employee))

Is This Answer Correct ?    0 Yes 1 No

how to find the second highest salary from emp table?..

Answer / waqas

Hi for second highest record follow this link
http://www.codingresolved.com/discussion/50/how-to-get-second-highest-record-in-sql#Item_2

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

What is a crud api?

0 Answers  


create SQL (both DML/DDL) statements appropriate for the creation of relational structures & constraints and other objects for a given case study, the population of these tables and the manipulation (querying/updating) of the stored data. 2. Create, develop and use the PL / SQL Program Units Procedures, Functions as a progression towards Object Oriented Relational Database Programming. 3. Package a collection of logically related Procedures and Functions together to further move towards development of Objects which reflect the principle of Data Abstraction whereby only an Object specified in the Interface is accessible to the end user. 4. Select, create, and use appropriate Database Triggers to impose agreed specific constraints on a Database Table. 5. Provide a full and detailed evaluation which includes a comprehensive test execution plan and its implementation for each of the above. Consider the following case study: Perilous Printing is a medium size printing company that does work for book publishers throughout UK. The company currently has 10 offices, most of which operate autonomously, apart from salaries, which are paid by the head office. Currently the sharing and communication of data, is carried out using multi- user networked access to a centralised RDBMS. Perilous Printing jobs consist of printing books or part of books. A printing job requires the use of materials, such as paper and ink, which are assigned to a job via purchase orders. Each printing job may have several purchase orders assigned to it. Likewise, each purchase order may contain several purchase order items. The following tables form part of the transactional RDB that the company uses: office (office_no, o_addr, o_telno, o_faxno, mgr_nin) staff (staff_no, nin, fname, lname, s_addr, s_telno, gender, dob, position, taxcode, salary, office_no) publisher (pub_no, p_name, p_city, p_telno, p_faxno, credit_code, office_no) book_job (job_no, pub_no, job_date, job_desc, job_type, job_status, supervisor_nin) purchase_order (job_no, po_no, po_date) po_item (job_no, po_no, it_no, qty) item (it_no, it_desc, amt_in_stock, price) office contains details of each office and the office number (office_no) is the key. Each office has a Manager represented by the manager’s national insurance number (mgr_nin). staff contains details of staff; the staff_no is the key. The office that the member of staff works from is given by office_no. publisher contains details of publisher and the publisher number (pub_no) is the key. Publishers are registered with the nearest office in their country, given by office_no, and they are given a credit code that can have the values “AA”, “AB”, “BB”, “BC”, “CC”, “CD” and “DD”. If a publisher is to be deleted then not only the publisher’s entry from the publisher table will have to be removed but all the data associated with the particular supplier has to be deleted too book_job contains details of publishing jobs and the job number (job_no) is the key. The publisher is given by the publisher number (pub_no) and the supervisor for the job by supervisor_nin. The job type can be either null or urgent; whereas the job_status can be “ongoing” or “completed” purchase_order contains details of the purchase orders for each job and the combination of job number and a purchase order number (job_no, po_no) form the key. Each printing job may have several purchase orders assigned to it. item contains details of all materials that can be used in printing jobs and the item number (it_no) is the key. po_item contains details of the items on the purchase order and (job_no, po_no, it_no) forms the key. In the above given database schema, descriptions are strings of characters (at most 30 characters long), any dates (except the job_ date) stored cannot be after the current system date, and quantities and prices are assumed to be non-negative numbers.

0 Answers  


give the syntax of grant and revoke commands? : Sql dba

0 Answers  


What are the advantages of pl sql over sql?

0 Answers  


What is a constraint? Tell me about its various levels.

0 Answers  


What are the default Oracle triggers??

3 Answers   CGI, Tech Mahindra,


What is record data type?

0 Answers  


How to set up sql*plus output format in oracle?

0 Answers  


What types of commands can be executed in sql*plus?

0 Answers  


Differences between UNIQUE and DISTINCT in select statements

26 Answers   ABS, DELL, Deloitte, Hewitt, Oracle, Verinon Technology Solutions, Wipro,


Types of joins ?

11 Answers   Polaris, TCS,


How do I view a procedure in sql?

0 Answers  


Categories