I've studied SQL many years ago but now my knowledge is very rusty. I will not post any code because my attempts didn't get even close. I am using MySQL.
if a have a table with products
product_id price
1 50
2 70
3 100
4 120
5 900
6 1100
I want to generate links like this on a web page
less than $70 //so that it narrows the result to ABOUT 30%
between $70 and $120 //so that it narrows the result to ABOUT 30%
more than $120 //so that it narrows the result to ABOUT 30%
I think I need a query that returns a minimum value a medium value
Using the example table, if the query returns a minimum value (70), 30% of the products will be bellow this value. A medium value, 30% of the products will be between the minimum value (70) and the medium value (120). Also 30% of the products will be above the medium value value (120).
This is roughtly my idea. I don't want a working code. I just want some example query that helps me to give me a "start".