473,513 Members | 4,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dept wise max sal

kiss07
99 New Member
Dear debas,

Fine and Thanks For Ur helping.

How can i find out department wise first 3 max salary?


O/P:

dept max(sal)
--------------------------------------------
HR 90000
89000
78000

TECH 67000
56000
45000

Regards,
Arun..
May 7 '07 #1
3 3674
chandu031
78 Recognized Expert New Member
Dear debas,

Fine and Thanks For Ur helping.

How can i find out department wise first 3 max salary?


O/P:

dept max(sal)
--------------------------------------------
HR 90000
89000
78000

TECH 67000
56000
45000

Regards,
Arun..
Hi,


SELECT
DEPTNO,SAL
FROM
( SELECT
DEPTNO,
SAL,
DENSE_RANK() OVER (PARTITION BY DEPTNO
ORDER BY
SAL DESC) MAX_SAL
FROM
EMP
)
WHERE
S < MAX_SAL
May 7 '07 #2
chandu031
78 Recognized Expert New Member
Dear debas,

Fine and Thanks For Ur helping.

How can i find out department wise first 3 max salary?


O/P:

dept max(sal)
--------------------------------------------
HR 90000
89000
78000

TECH 67000
56000
45000

Regards,
Arun..
Hi,

Again using Rank function , your query will look like this:

SELECT
DEPTNO,SAL
FROM
( SELECT
DEPTNO,
SAL,
RANK() OVER (PARTITION BY DEPTNO
ORDER BY
SAL DESC) MAX_SAL
FROM
EMP
)
WHERE
MAX_SAL < 4
May 7 '07 #3
debasisdas
8,127 Recognized Expert Expert
Ucan use the query
Expand|Select|Wrap|Line Numbers
  1. SELECT DEPTNO,SAL FROM ( SELECT DEPTNO, SAL, RANK() OVER (PARTITION BY DEPTNO
  2. ORDER BY SAL DESC) NUM FROM EMP ) WHERE NUM < 4
  3.  
To customise (dynamically execute) replace the hard coding by a variable.
Expand|Select|Wrap|Line Numbers
  1. SELECT DEPTNO,SAL FROM ( SELECT DEPTNO, SAL, RANK() OVER (PARTITION BY DEPTNO
  2. ORDER BY SAL DESC) NUM FROM EMP ) WHERE NUM < (&n+1)
  3.  
May 7 '07 #4

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

Similar topics

0
1238
by: Steve Covert | last post by:
Has anyone encountered problems with building an installer for a Windows app using Wise? In my case, the installation fails due an obfuscated dll. Instructions are provided for remedying this from Wise by using the sn.exe (Strong Name) utility in the .NET Framework. I have done this but made no difference. Any info appreciated. Steve
3
1890
by: T.S.Negi | last post by:
Hi All, I want to give sequence no group wise, as follows: Section EmpCode ----------------------- A 1001 A 1003 A 1009 B 1023
3
1679
by: Grant Rettke | last post by:
Hi folks, I'm currently evaluating a .NET installer platform. Basically, it has come down to either Wise or Installshield. It would be great to hear about your experiences with these product in deploying .NET apps. If you have experience deploying MSDE and the .NET runtime along with your app, that would be great.
4
1669
by: Chuck Cobb | last post by:
Can someone tell me how to do a bit-wise "And" in VB.Net - I've looked all over and can't find it. I thought the "And" in VB6 was replaced by a "BitAnd" function, but I can't find it anywhere and when I try to use it, it is unrecognized. Is it part of a class somewhere? Thanks, Chuck Cobb
16
5092
by: brooks | last post by:
It seems that the Access 97 ADT and 2000 ODE installers can seriously mess up a customer's computer. Sagekey sells a script to prevent this (~$500) which runs on Wise/Installshield (~$500) for a combined cost of about $1,000. Are there any less expensive installers which handle Access problems/conflicts? Brooks
0
1514
by: krishnarjun | last post by:
hi to all, suppose i created a sql table with one field..........then i inserted 5 records on that table....... if i use datagrid for accessing these records it ll shows all the records row wise........is there any tools or coding in C# asp.net web application, so that i can access these recoeds in column-wise....... i hope u ll reply me...
5
755
by: Enrique Cruiz | last post by:
Hello all, I am currently implementing a fairly simple algorithm. It scans a grayscale image, and computes a pixel's new value as a function of its original value. Two passes are made, first horizontally and second vertically. The problem I have is that the vertical pass is 3 to 4 times slower than the horizontal, although the code is...
0
1250
by: ARC | last post by:
Hello all, I currently have an old version of Wise Install Builder version 7, and in getting ready to go with Access 2007 installs with the Sagekey runtime script, I really don't want to continue using the old Wise installer, that had the famous blue box when installing. I want something more modern, however... In looking at the site for...
3
1730
by: suganya | last post by:
Hi I displayed the data from DB to DataList control. By default all data in datalist or datagrid is getting displayed row wise. Can any body guide me how to display the row wise data into column wise.
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7543
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.