473,402 Members | 2,053 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,402 software developers and data experts.

Displaying a Percentile Value Grouped by a separate Field in MS Access

2
I am a novice database user. I am analyzing a data set that is compiled monthly and I would like to use a SQL query to return multiple percentile values that are calculated / grouped by month.

I was able to find a SQL query provided in a previous thread that will give me a single percentile value for the entire dataset but not grouped by month.

SELECT Max([Value]) AS Percentile
FROM (SELECT TOP 50 PERCENT [Value]
FROM [Table/Query]
WHERE [Value] IS NOT NULL
ORDER BY [Value] ASC) AS [TemporaryTableName];

The above works great but returns a single value

Percentile
50th%Value

The output I am striving for is :

Month | 25thPercentile | 75thPercentile
02/2017 | 25th%Value for 02/2017 | 75th%Value for 02/2017
03/2017 | 25th%Value for 03/2017 | 75th%Value for 03/2017
04/2017 | 25th%Value for 04/2017 | 75th%Value for 04/2017

Any help would be greatly appreciated!!
Jul 20 '17 #1
3 1309
PhilOfWalton
1,430 Expert 1GB
It would help if we had details of all the fields in your relevant tables

Phil
Jul 20 '17 #2
JDVdb
2
Assume the fields are set up in a table as follows :

ID | Month | Usage

with some ID's having no Usage in a given month and with Usage having a minimum value of 1 and no maximum, creating a non-normal distribution with a very long tail. I have tried creating a function to calculate what I want using VBA but my data set has 900,000+ rows and the function works but does not perform well. So I am trying to understand if my desired output of displaying percentile rankings of aggregate usage by month can be achieved using an SQL query.
Jul 20 '17 #3
PhilOfWalton
1,430 Expert 1GB
I'm not very familiar with percentiles, but this may help

I have a table of Payments
Expand|Select|Wrap|Line Numbers
  1. PaymentID         Autonumber
  2. PaymentDate       Date
  3. PaymentAmount     Currency
  4.  
My first query QSubPercentile is
Expand|Select|Wrap|Line Numbers
  1. SELECT Month([PaymentDate]) AS Mnth, Payments.PaymentAmount, 
  2. (SELECT Count(*) FROM Payments As U 
  3. WHERE [PaymentAmount] < [Payments].[PaymentAmount])+1 AS Rank, 
  4. (SELECT Count(*) FROM Payments) AS RCount, ([RCount]-[Rank])/[RCount] AS Percentile
  5. FROM Payments
  6. WHERE (((Year([PaymentDate]))=2010))
  7. ORDER BY Payments.PaymentAmount;
  8.  
Note, I limited it to 1 year otherwise there would have been confusion over months.

The second query QPercentile is
Expand|Select|Wrap|Line Numbers
  1. SELECT QSubPercentile.Mnth, Max(QSubPercentile.PaymentAmount) AS MaxOfPaymentAmount
  2. FROM QSubPercentile
  3. WHERE (((QSubPercentile.Percentile)<=[Input Percentile]))
  4. GROUP BY QSubPercentile.Mnth
  5. ORDER BY QSubPercentile.Mnth;
  6.  
  7.  
Note that you seem to have to put the figure in with a leading 0 (0.75 not .75)

I have no idea whether this is giving the correct results.

Phil
Jul 20 '17 #4

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

Similar topics

4
by: Tom Esker | last post by:
I've got Javascript in a form that adds up all of the numbers in a column of form fields and displays a total. It works great if every field has an initial value of 0, but if any of them are null,...
2
by: Steve | last post by:
Does any anyone have a procedure for a query where a calculated field returns the previous record's value in another field. For example: A F A Z F M Z The primary key is in random...
1
by: K. Davis | last post by:
I need to increment the maximum value of a field of a table by 1 when a form opens a blank record. (e.g. =max(!![trip_number}) so the logic and references are working at the form level. I've...
1
by: mandakini | last post by:
Hello freinds I am working on this url http://72.36.156.243/compbuild.php Here I am using ifram and displaying dynamic value I don't know how to use iframe as array how to assign array and...
2
by: blast | last post by:
hi, thanks for heping me in my previous issues....i m really confused reg this issue, please help me: i'm selecting a row from table a for that particular row there are 3 persons (assignee,...
1
by: klausdh | last post by:
Hi all, I am just about to migrate a database from mdb to adp format - and experienced a real difficulty in retrieving a table field's default value by VBA code (using the ADODB 2.8 Library). In...
3
by: BobbyD1120 | last post by:
I have created a inventory tracking database and I want to show/hide certain fields based on the device category. The deviceCategory field is a lookup field to a table that lists all the different...
4
by: nedryerson | last post by:
Hi, I'm trying to get a certain field to appear only when a value from another combobox field is selected. Specifically, when "Sample Rejected" is selected in the field "PcrLabResults," I would...
0
MMcCarthy
by: MMcCarthy | last post by:
Hi everyone If anyone could help out an access user who is trying to retrieve the value in a hidden field on an asp.net page could they take a look at this question in the Access forum. Thank...
1
beacon
by: beacon | last post by:
Hi everybody, I have a combo box field in a table with a number data type that has a row source to another table that has the text value for the item selected. Now, in one of my queries, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...

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.