How can you select a fixed number of rows from a table, in which a timestamp column, and the return rows are equally distant from each other. I need these points as sample points to use to plot a timeseries. I am aware of other techniques to solve this problem such as crossfilter, etc, but I want to be able using the server, for now.
For example, the table below: (timestamp is simplified just for clarity)
id key val timestamp
1 'a' 100 1am
2 'b' 120 2am
3 'c' 130 3am
4 'd' 140 4am
5 'e' 130 5am
6 'f' 135 6am
7 'g' 136 7am
8 'h' 139 8am
9 'i' 149 9am
10 'j' 140 10am
11 'k' 140 11am
12 'l' 135 12pm
so I want to be able to run a query that will return a sample of size 3, for example, and it should return rows 1, 5 and 9.
I dont want to use the id, because my table is more complicated than this, and I will be applying where clauses, etc to my query, and so using ID is not going to work.
From working with other RDBSs I am aware of RANK, but it doesnot seem that it exists in mysql, I saw workarounds, like the one here, but I don't think it is a clean way to write mysql.
Any suggestions on how to approach this problem?