473,569 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Percentile Query?

76 New Member
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!
Jan 28 '09 #1
5 4506
ADezii
8,834 Recognized Expert Expert
@artemetis
  1. 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)!
  2. First, a couple of very simple Assumptions:
    1. Table Name is tblEmp
    2. empUID is the Primary Key (Data Type not relevant)
    3. empPerf is a BYTE Data Type, must be >=0 and <=100, and cannot be NULL
  3. Enough already, below please find the SQL and the Function code below:
    Expand|Select|Wrap|Line Numbers
    1. SELECT Employees.EmployeeID, Employees.empPerf, fCalculatePercentile([empPerf]) AS Percentile
    2. FROM Employees
    3. ORDER BY Employees.empPerf DESC;
    Expand|Select|Wrap|Line Numbers
    1.  
    2. Public Function fCalculatePercentile(bytPerf As Byte) As String
    3. Dim MyDB As DAO.Database
    4. Dim rstPercentile As DAO.Recordset
    5. Dim intGreater As Integer
    6. Dim intLess As Integer
    7. Dim intAllScores As Integer
    8. intAllScores = DCount("*", "Employees")     'Total Number of Scores
    9. Set MyDB = CurrentDb
    10. Set rstPercentile = MyDB.OpenRecordset("Employees", dbOpenForwardOnly)
    11. With rstPercentile
    12.   Do While Not .EOF
    13.     If bytPerf >= ![empPerf] Then
    14.       intGreater = intGreater + 1       'Increment > Counter
    15.     Else
    16.     End If
    17.     .MoveNext
    18.   Loop
    19. End With
    20. rstPercentile.Close
    21. Set rstPercentile = Nothing
    22. fCalculatePercentile = Format$(intGreater / intAllScores, "Percent")
    23. End Function 
    24.  
Jan 28 '09 #2
ADezii
8,834 Recognized Expert Expert
Oops, wrong SQL!
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT tblEmp.empUid, tblEmp.empPerf, fCalculatePercentile([empPerf]) AS Percentile 
  3. FROM tblEmp 
  4. ORDER BY tblEmp.empPerf DESC; 
  5.  
Jan 28 '09 #3
NeoPa
32,564 Recognized Expert Moderator MVP
Try something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP [X Percent] PERCENT empUID,
  2.                                empPerf
  3. FROM tblEmp
  4. ORDER BY empPerf DESC
Jan 29 '09 #4
artemetis
76 New Member
@NeoPa

Thanks folks...thanks Neo!
This looks like it will work for me...question.. .is it fair to say that using the following
Expand|Select|Wrap|Line Numbers
  1. WHERE (((tblEmp.empPerf)<>0))
will exclude any record with a zero value from being calculated?
Feb 4 '09 #5
NeoPa
32,564 Recognized Expert Moderator MVP
@artemetis
You're welcome :)
@artemetis
Yes indeed.
Feb 5 '09 #6

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

Similar topics

2
3419
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...
29
2477
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 '" &...
9
3115
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...
3
5374
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...
2
3277
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...
3
13460
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...
1
14285
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...
28
19650
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?
19
11149
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...
0
7695
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, 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...
0
7612
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
7922
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
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
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...
1
5509
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
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
1209
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.