mysql - Filter Rows with time difference -


i have "readings" table columns

  1. timestamp datetime
  2. channel_id integer
  3. value decimal
  4. test_id integer

now want filter rows test_id can do. in result number of rows much. suppose if use channel number 2,3 , 5 test_id 17 , if log data every second there 10k rows.

when plot graph there many data graph lines not visible clearly, make them visible need filter out rows.

i need in filtering of rows time difference between 2 records should few seconds lets 10 seconds. in data not consecutive.

any appreciated.

the sample data follows:

24-05-2016 08:00:55 | 2 | 10.23  | 17  24-05-2016 08:00:55 | 3 | 100.23 | 17  24-05-2016 08:00:55 | 5 | 12.23  | 17  24-05-2016 08:00:56 | 2 | 09.23  | 17  24-05-2016 08:00:56 | 3 | 12.23  | 17  24-05-2016 08:00:56 | 5 | 11.23  | 17  24-05-2016 08:00:57 | 2 | 09.23  | 17  24-05-2016 08:00:57 | 3 | 01.23  | 17  24-05-2016 08:00:57 | 5 | 11.23  | 17  24-05-2016 08:00:58 | 2 | 09.23  | 17  24-05-2016 08:00:58 | 3 | 01.23  | 17  24-05-2016 08:00:58 | 5 | 11.23  | 17 

instead of filtering can aggregate data period using group functionality. example, 10-second periods can calculated timestamps using formula:

round(unix_timestamp(timestamp)/10) 

so, formula can added group query, query can aggregate data on period:

select test_id,channel_id,round(unix_timestamp(timestamp)/10),     min(value), max(value), avg(value),count(*) your_table some_conditions gropu test_id,channel_id,round(unix_timestamp(timestamp)/10) 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -