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


Write a query to find second highest salary of an employee.

Answers were Sorted based on User's Feedback



Write a query to find second highest salary of an employee. ..

Answer / gautam poonia

SELECT sal
FROM (SELECT sal FROM emp
ORDER BY sal desc)
WHERE RowNum<=2
minus
SELECT sal
FROM (SELECT sal FROM emp
ORDER BY sal desc)
WHERE RowNum<=1

Is This Answer Correct ?    17 Yes 1 No

Write a query to find second highest salary of an employee. ..

Answer / cooldude

select max(sal) from Emp where sal < (select max(sal) from
Emp)

Is This Answer Correct ?    14 Yes 2 No

Write a query to find second highest salary of an employee. ..

Answer / gvmahesh

I write the query for this question using OLAP functions.

select e1.* from (select ename,sal,rank()
over(order by sal desc) rank from emp) e1
where e1.rank=2;

Is This Answer Correct ?    5 Yes 1 No

Write a query to find second highest salary of an employee. ..

Answer / sathish p

select e1.* from (select ename,sal,rank()
over(order by sal) rank from emp) e1
where e1.rank=2;

Is This Answer Correct ?    3 Yes 0 No

Write a query to find second highest salary of an employee. ..

Answer / monika

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

Is This Answer Correct ?    8 Yes 6 No

Write a query to find second highest salary of an employee. ..

Answer / mubin ahmad

select salary from employee e1 where 2=(select count(*)
from employee e2 where e2.salary>=e1.salary)

Is This Answer Correct ?    2 Yes 0 No

Write a query to find second highest salary of an employee. ..

Answer / humayun quaiser

slect max(sal) from emp
where sal not in (select max(sal) from emp);

or

select max(sal) from emp
where sal<(select max(sal) from emp);

or

select distinct sal from emp e
where 1=(select count(distinct sal) from emp
where sal>e.sal);

Is This Answer Correct ?    2 Yes 0 No

Write a query to find second highest salary of an employee. ..

Answer / versaites

select top 1 emp_total_sal,emp_name from (
select top 2 emp_total_sal,emp_name from employee_table
ORDER BY emp_total_sal DESC) a
ORDER BY emp_total_sal ASC

Is This Answer Correct ?    4 Yes 3 No

Write a query to find second highest salary of an employee. ..

Answer / manoranjan

to select the nth highest salary from emp table

select distinct(a.sal) from emp a where &n=
(select count(distinct(b.sal))from emp b where a.sal<=b.sal);

Is This Answer Correct ?    3 Yes 2 No

Write a query to find second highest salary of an employee. ..

Answer / senorita

select ename,salary from (select rownum,ename,salary from
emp
order by desc) where rownum=2;

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More SQL PLSQL Interview Questions

What are the 3 types of behavioral triggers?

0 Answers  


First round ------------------- - Procedure - Packages - Views - Virtual tables - Can we use dcl with in function? - Joins and few scenarios - Triggers and its type - Pragma, type and its functionality - How to create db link in oracle - Materialized view - How to find duplicate values from table? - Cursor and its functionality - Write a script to display friday and its date from a entire year. - Exception Handling Second round ------------------------ Gave a scenario like. Need to write a function to perform. When user try to change a password. It must not be last five password and a given password can be combination of characters, symbols, upper and lower case.

0 Answers   Prodapt,


what is the difference between rownum pseudo column and row_number() function? : Sql dba

0 Answers  


What are sql constraints?

0 Answers  


How can I delete duplicate rows?

0 Answers  


while loading data into database how can u skip header and footer records in sql*loader

1 Answers   Oracle,


What is oracle ? why we should go for oracle database instead of diffrent databases available in the industry.

5 Answers   Polaris,


Is mariadb nosql?

0 Answers  


How to add, remove, modify users using sql?

0 Answers  


Can we use pl sql in mysql?

0 Answers  


How many types of triggers exist in pl/sql?

0 Answers  


can we write stored function in out parameters? how to call through select statement? how to written more than one value plz give the exmple?

1 Answers  


Categories