how 2 find out nth salary.plz write sql qurires

Answers were Sorted based on User's Feedback



how 2 find out nth salary.plz write sql qurires ..

Answer / shankar

Hi...
here is the query to find out the n'th maximum salary

note: 1.'emp' is Table name & 'sal' is column name.
2.'distinct' is used for finding the unique value
3.'count' is for counting the values.

Query:
------

SELECT * from emp
where sal = (SELECT distinct(sal) from emp x
where &n = (SELECT count(distinct(sal)) from
emp where sal >= x.sal));

Is This Answer Correct ?    4 Yes 0 No

how 2 find out nth salary.plz write sql qurires ..

Answer / guest

select top 1 salary from(select Distinct top 2 salary from
employee order by salary desc)order by salary

Is This Answer Correct ?    1 Yes 1 No

how 2 find out nth salary.plz write sql qurires ..

Answer / a sameer

By using alias name too we can generate the query
A and B are two alias name for the employee table name

Query:-

select A.* from employee A where N=(selet count(Distinct
B.sal) from employees B where B.Sal > A.sal);


If any one want 2 or any other salary jut replace "the no."
required in place of N, to get the answer.


Hope might understand

Is This Answer Correct ?    1 Yes 1 No

how 2 find out nth salary.plz write sql qurires ..

Answer / rafi

Select * from (Select emp.*.dense_rank()over (order by sal
desc) a from emp) where a=&n;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Manual Testing Interview Questions

Hi, Can anybody send some test scenarios or testcases sample for Finance domain on sales and accounting application. I am very new to Finance domain. Or else please send to my mailID "manojdalai2004@gmail.com". Thanks in Advance, Manoj

0 Answers  


What is srs and brs document?

0 Answers  


Once automated, what are the types of functionality provides the highest Return On Investment (ROI) to the company?

1 Answers   ASD Lab,


What r the major problems faced in manual testing?

2 Answers  


Write Test case on even/Odd or Prime Number from 1 to 100 ?

1 Answers  






What is manual testing and what is it process?

0 Answers   TCS,


who assigns siverity for a bug? is it test engnr, test lead or devlopment lead?

4 Answers  


What is role of a tester in the requirement phase?

2 Answers  


What is Test Design ?( Urgent) and Test Design for Printer?

0 Answers   Tech Mahindra,


Hi Friends, Please help me in providing System test cases examples Thanks in Advance

0 Answers  


HOW DO U EXECUTE THE CASES WHEN THE TIME IS NOT SUFFICIENT TO EXECUTE ALL THE TEST CASES?

8 Answers  


Suppose when you click on message icon in your mobile phone , if it is giving a message "Error,Message cannot be opened", Wha will u do? how do you rise a defect? /

2 Answers  


Categories