Hello!
It's me again.
tblEmp
-->empUid - self explanatory
-->empPerf - ranking from 0 - 100
I'm interested in creating a query that displays the top x% (eg, 20%) of employee performance, based on empPerf. Qry operator will be prompted for value of X%.
I'm not too familiar with stats, but searched through the site and found l was only able to find something regarding Excel.
In advance........ ......THANKS!
5 4506 ADezii 8,834
Recognized Expert Expert @artemetis - I wrote a very simple Algorithm that will calculate a Percentile Rank as the proportion of Scores in a Distribution that an Employee's score is greater than or equal to. As an example, if Employee X received a Score (empPerf) of 95, and this Score is greater than or equal to 88% of the other Employee's Scores, then his/her Percentile Rank would be in the 88th Percentile. This code will not win any coding awards, it ain't even pretty, but it do work! (LOL)!
- First, a couple of very simple Assumptions:
- Table Name is tblEmp
- empUID is the Primary Key (Data Type not relevant)
- empPerf is a BYTE Data Type, must be >=0 and <=100, and cannot be NULL
- Enough already, below please find the SQL and the Function code below:
- SELECT Employees.EmployeeID, Employees.empPerf, fCalculatePercentile([empPerf]) AS Percentile
-
FROM Employees
-
ORDER BY Employees.empPerf DESC;
-
-
Public Function fCalculatePercentile(bytPerf As Byte) As String
-
Dim MyDB As DAO.Database
-
Dim rstPercentile As DAO.Recordset
-
Dim intGreater As Integer
-
Dim intLess As Integer
-
Dim intAllScores As Integer
-
intAllScores = DCount("*", "Employees") 'Total Number of Scores
-
Set MyDB = CurrentDb
-
Set rstPercentile = MyDB.OpenRecordset("Employees", dbOpenForwardOnly)
-
With rstPercentile
-
Do While Not .EOF
-
If bytPerf >= ![empPerf] Then
-
intGreater = intGreater + 1 'Increment > Counter
-
Else
-
End If
-
.MoveNext
-
Loop
-
End With
-
rstPercentile.Close
-
Set rstPercentile = Nothing
-
fCalculatePercentile = Format$(intGreater / intAllScores, "Percent")
-
End Function
-
ADezii 8,834
Recognized Expert Expert Oops, wrong SQL! -
-
SELECT tblEmp.empUid, tblEmp.empPerf, fCalculatePercentile([empPerf]) AS Percentile
-
FROM tblEmp
-
ORDER BY tblEmp.empPerf DESC;
-
NeoPa 32,564
Recognized Expert Moderator MVP
Try something like : - SELECT TOP [X Percent] PERCENT empUID,
-
empPerf
-
FROM tblEmp
-
ORDER BY empPerf DESC
@NeoPa
Thanks folks...thanks Neo!
This looks like it will work for me...question.. .is it fair to say that using the following - WHERE (((tblEmp.empPerf)<>0))
will exclude any record with a zero value from being calculated?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jaysonsch |
last post by:
Hello!
I am having some problems with a database query that I am trying to do.
I am trying to develop a way to search a database for an entry and
then edit the existing values. Upon submit, the new values are updated
in all corresponding tables (the function of the pages in question).
However, on the page that does the DB update, I also...
|
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules" for when
and how to use single quotes and double quotes in ASP?
thanks!
----------------------
SQL = SQL & "WHERE '" &...
|
by: netpurpose |
last post by:
I need to extract data from this table to find the lowest prices of
each product as of today. The product will be listed/grouped by the
name only, discarding the product code - I use SUBSTRING(ProductName,
1, CHARINDEX('(', ProductName)-2).
I can get this result, but I had to use several views (totally
inefficient). I think this can be...
|
by: Harvey |
last post by:
Hi,
I try to write an asp query form that lets client search any text-string and
display all pages in my web server that contain the text. I have IIS 6.0 on a
server 2003. The MSDN site says there is a sample file called Ixtrasp.asp,
but I could not find it in my system although I installed indexing service. I
followed the steps in MSDN...
|
by: jd142 |
last post by:
Normally when people ask about getting the Nth percentile from a group,
the response is to write a couple of VBA modules. But it seems to me
there's a simpler way that just uses 2 queries. You might even be able
to get it down to one query if you nest them.
Here's how I get the 25th percentile number from a table, where
mynumber is the...
| |
by: Dave Veeneman |
last post by:
I'm looking from an algorithm that will do a statistics calculation for me--
it's the first time 'Numerical Recipies in C' has failed me! A normal
distribution table tells me the probability (by percentile) of an item,
given something called a z-score. If I have a z-score, I can look up the
probability in a distribution table.
There are...
|
by: Joe |
last post by:
Has anyone written a percentile rank algorithm that they can share or
know of a good resource that defines the algorithm. I'm starting a
project that involves percentile ranks, logistic and linear regression.
If not c# any language or pseudo code would be very useful. Thank you.
Joe
--
Sent via .NET Newsgroups...
|
by: riaane |
last post by:
Hey clever people, Excel has the =PERCENTILE function. This calulates a percentile value from an array of values. Is there any equivalent in Access?
|
by: SachinPatel |
last post by:
ADezii,
i have been reading your solution to this percentile problem and believe you can help me.
I have a similar problem with creating a percentile in access 2007.
My table is called "TBL_DATA" and the field with all the values i would like to gain a percentile for is called "DAYS"
i want to develop a query which shows the following...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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...
| |
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. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |