# Distribution of table in time

I have a MySQL table with about 3000 rows per customer. Among the columns is a datetime area, which is mutable, so the rows aren't in sequential order.

I would certainly such as to envision the moment circulation in a graph, so I require a variety of specific datapoints. 20 datapoints would certainly suffice.

I can do this:

select timefield from entries where uid = ? order by timefield;


and also consider every 150th row.

Or I can do 20 different questions and also make use of limit 1 and also offset.

Yet there have to be an extra reliable remedy ...

0
2019-05-09 11:00:56
Source Share

For whatever factor, your instance just functions when the where @recnum makes use of a much less than driver. I assume when the where remove a row, the rownum does not get incremented, and also it can not match anything else.

If the initial table has a vehicle incremented id column, and also rows were put in sequential order, after that this need to function:

select timefield from entries
where uid = ? and id % 150 = 0 order by timefield;


Of training course that does not function if there is no relationship in between the id and also the timefield, unless you do not in fact respect obtaining equally spaced timefields, simply 20 arbitrary ones.

0
2019-05-12 08:01:46
Source

Something similar to this involved my mind

select @rownum:[email protected]+1 rownum, entries.*
from (select @rownum:=0) r, entries
where uid = ? and rownum % 150 = 0


I do not have MySQL at my hand yet possibly this will certainly aid ...

0
2019-05-10 05:34:17
Source

Related questions