Hello Everyone,
I have a table with the following structure:
Employee ID, Salary.
I want to find employees with top 5% salaries.
Appreciate if someone may please help.
Thanks,
Rupinder
4 2782 azimmer 200
Recognized Expert New Member
Hello Everyone,
I have a table with the following structure:
Employee ID, Salary.
I want to find employees with top 5% salaries.
Appreciate if someone may please help.
Thanks,
Rupinder
-
select top 5 percent emp_id, salary
-
from myTable
-
order by salary desc
-
-
select top 5 percent emp_id, salary
-
from myTable
-
order by salary desc
-
Thanks for the suggestion but the above query will return top 5 percent rows with salary in descending order. What I am trying to achieve is to have the rows with salary in top 5 percent. for ex: if maximum salary is 100, I want to retrieve all rows with salary >=95.
Thanks,
Rupinder
azimmer 200
Recognized Expert New Member
Thanks for the suggestion but the above query will return top 5 percent rows with salary in descending order. What I am trying to achieve is to have the rows with salary in top 5 percent. for ex: if maximum salary is 100, I want to retrieve all rows with salary >=95.
Thanks,
Rupinder
OK, that's different: -
select empid, salary
-
from mytable
-
where salary >= (select 0.95*max(salary) from mytable)
-
OK, that's different: -
select empid, salary
-
from mytable
-
where salary >= (select 0.95*max(salary) from mytable)
-
Thanks, it worked.
In my actual problem, I had a table with employee and their scores for various campaigns and I had to find top 5% of the cumulative scores of an employee. So, I used temporary tables and applied your logic on the temporary table to make it work.
Thanks once again,
Rupinder
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: deprins |
last post by:
Hello,
I have wrote a stored procedure but its real slow. Its activated by a
button on web page but its takes to long to process and the web server
gives a timeout message after 5 minutes.
Is...
|
by: DB_2 |
last post by:
Hello,
I created the following stored procedure. (Please ignore the logic in
it; at this point it is not complete and I am trying to get the basic
structure working first.)
CREATE PROCEDURE...
|
by: Not Me |
last post by:
Hey,
Coming back to a piece of work I did a while back, which used a stored
procedure to populate a list box. The SP takes a single parameter, and
I think this is the reasoning for using 'exec'...
|
by: Chris |
last post by:
Hi,
I created a VB SQL CRL Stored procedure for calculating a value. Value
is returned as below
Using sConn4 As New SqlConnection("context connection=true")
sConn4.Open()
scmd = New...
|
by: vickilynnpgc |
last post by:
I have a tsql stored procedure I want to drag from server explorer onto an
xsd file. I get the error ' xml schema could not be interpreted'. The stored
procedure does a select from a udf, that's...
| |
by: charlesg |
last post by:
I have a query that select rows from the employees,salary_head and salary_group tables
this is the query
SELECT TOP 100 PERCENT dbo.salary_head.salary_group_id, dbo.salary_group.salary_group,...
|
by: satish mullapudi |
last post by:
Hi,
I am using DB2 v8.2 & jdk 1.4.
1. I have a java program which returns an array which contains 1 to 5
numbers.
The code:
public class ArrayTest
{
public static final int ARRAY_SIZE = 5;...
|
by: sheenaa |
last post by:
Hello Members,
I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005.
What i have used on forms :: ?
On my first form i have used some...
|
by: zrtv |
last post by:
hi All,
Iam new in oracle stored procedure, i have one stored procedure and it has to be accessed from vb6. my stored procedure as follows
-- employee salary will be entered by the user and...
|
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,...
|
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...
| |
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: 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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |