473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Top 10 salaries

hi I want to know about a Query regarding Top 10 salaries from Emp and I want 1 to 10 numbers at the Regarding salaries


I want Out put like 10000 1
7500 2
5500 3
3500 4
Jan 30 '08 #1
3 1783
debasisdas
8,127 Expert 4TB
try to use this

Expand|Select|Wrap|Line Numbers
  1. SELECT EMPNO,ENAME,SAL,DENSE_RANK() OVER (ORDER BY SAL DESC) AS RK FROM EMP ORDER BY SAL DESC
  2.  
Jan 30 '08 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. select rownum as rank ,ename,sal 
  4. from (select ename,sal from emp order by sal desc) 
  5. where rownum<=&n
  6. //
  7.  
  8. SELECT min(sal)
  9. FROM (SELECT sal
  10. FROM emp 
  11. order by sal desc)
  12. WHERE rownum<(&nth_heighest+1);
  13. //
  14.  
  15. select ename, sal
  16. from (select ename,sal,dense_rank() over(order by sal desc) dr from emp)
  17. where dr = &rnk
  18. //
  19.  
  20. SELECT *
  21.  FROM (
  22.    SELECT empno, ename, sal,
  23.    RANK() OVER (ORDER BY sal DESC) EMPRANK
  24.    FROM emp)
  25. //
  26.  
  27.  
Jan 30 '08 #3
amitpatel66
2,367 Expert 2GB
hi I want to know about a Query regarding Top 10 salaries from Emp and I want 1 to 10 numbers at the Regarding salaries


I want Out put like 10000 1
7500 2
5500 3
3500 4

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT salary, rn FROM
  3. (SELECT empno,salary,rownum rn from emp ORDER BY salary desc) WHERE rn <= 10
  4.  
  5.  
Jan 31 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Niy | last post by:
how to get that with SQL query?
0
by: Toralf Kirsten | last post by:
Hi, we use DB2 V8.1 on a Linux machine. Situation: To store salary data we have designed a star schema containing the dimension tables product, office, time and the the fact table salaray...
11
by: --CELKO-- | last post by:
I am getting material for a second edition of my SQL PUZZLES book together of the next few months. 1) If anyone has a new puzzle, send it to me. You will get your name in print, fame, glory and...
4
by: MattB | last post by:
I've asked my employer for a raise (which of course I believe is justified). They are asking me to provide some input and I'm looking for a good resource(s) for what we typically make. Any links...
15
by: Sachin | last post by:
Hi Everybody, I am doing a project and I desire to know can we connect SQL database in C programs and use them ? Can any body can help me? Please explain me the whole concept & give me the code...
0
by: Bala | last post by:
FOR MORE DETAILS AND POST YOUR RESUMES ON http://polticsinfs.blogspot.com/
0
Breezwell
by: Breezwell | last post by:
Hi everyone, This is a question for all of you out there who also work as Access database designers and administrators. I know there are a lot of variables to consider when estimating your...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.