:: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Categories >> Software >> Databases >> SQL PLSQL


 Oracle interview questions  Oracle Interview Questions (2036)
 SQL Server interview questions  SQL Server Interview Questions (1076)
 MS Access interview questions  MS Access Interview Questions (24)
 MySQL interview questions  MySQL Interview Questions (194)
 Postgre interview questions  Postgre Interview Questions (6)
 Sybase interview questions  Sybase Interview Questions (22)
 DB Architecture interview questions  DB Architecture Interview Questions (5)
 DB Administration interview questions  DB Administration Interview Questions (213)
 DB Development interview questions  DB Development Interview Questions (53)
 SQL PLSQL interview questions  SQL PLSQL Interview Questions (771)
 Databases AllOther interview questions  Databases AllOther Interview Questions (106)
how to find the second highest salary from emp table?
 Question Submitted By :: SQL-PLSQL
I also faced this Question!!     Answer Posted By  
# 1
select max(sal) from emp
where sal not in (select max(sal) from emp )
Is This Answer Correct ?    1024 Yes 121 No
# 2
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
Is This Answer Correct ?    708 Yes 90 No
# 3
use this query. it works great.

select max(sal) from table_name where sal<(select max(sal)
from table_name)
Is This Answer Correct ?    400 Yes 55 No
# 4
Please put the below query, u will get the second highest
salary of the table :---

select sal from(select sal from
(select distinct sal from emp order by sal desc)
where rownum<=2 order by sal asc)
where rownum=1;
Is This Answer Correct ?    481 Yes 260 No
Gourvendra Singh
# 5
Follow the following Query, You get the second highest
SQL> Select level,Max(sal) from emp
Where level=&level connect by prior sal>sal
group by level;
SQL> Enter the level No=2 (Here enter 2 manually)

Then you will get the 2nd highest salary.
If you want 3rd Highest salary, then enter level no=3.
Is This Answer Correct ?    202 Yes 103 No
# 6
select max(sal) from emp where sal < (select max(sal) from
Is This Answer Correct ?    79 Yes 13 No
Muhammed Zaheer
# 7
select sal from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp));
Is This Answer Correct ?    26 Yes 3 No
Anuj Maheshwari
# 8
SELECT MAX(sal) from emp a where &n=(select COUNT(DISTINCT
(SAL)) from emp b where a.sal<=b.sal)
Is This Answer Correct ?    33 Yes 20 No
# 9
second method is
select sal from emp e1 where 2=(select count(distinct(sal))
from emp e2 where e1.sal<=e2.sal);
Is This Answer Correct ?    33 Yes 20 No
Radha Sri Seshu
# 10
select max(salary) from table01
where salary <(select max salary from table01)

in mainframe env
Is This Answer Correct ?    23 Yes 12 No
Shiva Kumar

Other SQL PLSQL Interview Questions
  Question Asked @ Answers
Hi All, I am new to both this blog and technology. I was able to see a response for one of the questions on triggers as below. I would like to know why are we using " if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then" instead, can't we use " if sysdate = 'sunday' then". I can understand the use of "rtrim", but dont know y v r using to_char. I have seen this in many cases but did not get a convincible explaination. Please help me with this and do excuse if this question sounds silly. Thanks in advance...... create or replace trigger trg_sun before insert on <table name> begin if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then raise_application_error(-20345,'no transaction in sunday'); end if; end trg_sun;   1
How can I create a table from another table without copying any values from the old table?   8
i have a table like this. cityno cityname mails 1 BANGALORE 8KM 2 HSR LAYOUT 20KM 3 MEJISTIC 30KM 4 JAYADEVA 55KM 5 ITPL 80KM 6 HEBBAL 115KM I HAVE DATA LIKE THIS I WANT O/P LIKE THIS DISTANCE NO.OFCITY 0-50KM 3 51-100KM 2 101-150KM 4 AND SO ON oracle 4
What is the result, when NULL is compared with NULL? TCS 19
How can I pass the inner procedure value to outer procedure ?   2
If an unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE?   4
i have a table eno dno sal 1 10 200 2 10 150 3 10 100 4 20 75 5 20 100 i want to get sal which is less than the avg sal of thri dept. eno dno sal 2 10 150 3 10 100 4 20 75 IBM 8
Which one of the following join types will always create a Cartesian Product? 1. CROSS JOIN 2. LEFT OUTER JOIN 3. RIGHT OUTER JOIN 4. FULL OUTER JOIN 5. INNER JOIN   2
What are the blocks in stored procedure? Microsoft 5
table structure: ---------------- col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10 01-mar-2012 11:12:46 01-mar-2012 11:11:23 Write a query to display the result as shown below: col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10   2
What is difference between Procedures and Functions ? Hi-Caliber-IT 5
a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining. CGI 3
For more SQL PLSQL Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright 2013  All Rights Reserved.   ::