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 |
He has given table attributes- empid,empfirstname,emplastname,MangerID.And he asked write query to display empfirstname and mangername?
What is the diff between CLient, Customer and End User?
7 Answers JVS, Societe Generale,
what is Gui testing and how is it performed
what is difference between BVA and Equivalence Partitioning ? can u explain BVA for three digits?
Neelima, Can you please brief what are the 15 testing issues. I'm aware of 5 Software developement life cycle.
what is the difference between product and application?
What is Application Performance testing and Operational performance testing
wat is ur involvement in test plan
difference between sanity testing and smoke testing?
11. Do any of the authoring tools you use have features to help make your Web sites accessible?
How many scripts u use to run daily?
When should you begin testing?