user785552
user785552

Reputation: 11

How to implment a weighted percentile with MySQL

I have a large data set which includes the prices a particular product is sold at across stores. I need to found the lowest and highest price at which 80% of sales occurred. for example with the following data the lowest would be 1.1 and the highest 1.9:

price   sales
-----   -----
1       2
1.1     2
1.2     2
1.4     3
1.5     4
1.6     2
1.7     2
1.9     1
2.2     1
2.5     1

Can any one suggest a way to do this?

Thanks

Upvotes: 1

Views: 641

Answers (1)

msw
msw

Reputation: 43507

MySQL is a database not well suited to numerical methods. R is one of many programmable statistical suites that can source data from databases such as MySQL.

The RODBC package is probably a good starting point.

Upvotes: 1

Related Questions