how 2 find out nth salary.plz write sql qurires
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
what is security test,what is meant by authentication &autherization
hi what are the test cases for web application..i need these example..please..mail me at mina_ims@yahoo.com
what is the difference between test strategy and test methodology?
What is known Issue???
Why testing is required?
28 Answers Cap Gemini, Infosys,
what are the -ve test cases for Railway Ticketing System?
what are the risks and contingencies u had in ur project?
can anyone tell me the different types of testing with starting letter A specify atleast 5 ?? eg: adhoc testing,alpha testing.
What is Manual Testing?Can I Know the best Institute in Hyderabad & the Best Institute to get Projects?Plz kindly help me ? Iam thinking to learn Testing? My qualification : BCA with MBA .
47 Answers AppLabs, IBM, MAHINDRA,
What is performance tuning? What are tools of performance testing?
Why do we do Smoke Testing?
how many functional testcases u can write for triangle