Jump to content

Query


sandy1028

Recommended Posts

Hi,

 

select * from `tablename` where 'fieldname` < now() and fieldname` > (now()-interval 1 day);

 

This gives the result of all the records for 24 hours.

 

 

The timestamp stored in database is like this:

2007-09-16 19:30:02 |

| 2007-09-16 19:40:02 |

| 2007-09-16 19:50:02 |

| 2007-09-16 20:00:02 |

| 2007-09-16 20:10:02 |

| 2007-09-16 20:20:02 |

| 2007-09-16 20:30:02 |

| 2007-09-16 20:40:02 |

| 2007-09-16 20:50:02 |

| 2007-09-16 21:00:01 |

| 2007-09-16 21:10:02 |

| 2007-09-16 21:30:02 |

| 2007-09-16 21:30:02 |

| 2007-09-16 21:40:02

 

 

 

How to write a query to fetch data between these two 2007-09-16 21:40:02 and 2007-09-16 21:30:02 and

2007-09-16 21:30:02 and 2007-09-16 21:30:02 and so on........

 

Between these timestamps there is a records.

I should find the average between each timestamps

 

 

Please help me in writing a query to find the average of each ten minutes records in database from current timestamp to previous day

Link to comment
https://forums.phpfreaks.com/topic/69861-query/
Share on other sites

Finding the records between each 10 mints interval is not a problem , but grouping them to find avg of timestamps with a groupcolumn which has a unique value for each interval is the problem.

 

As we can't loop it for each interval using MySQL better try with PHP.

 

 

Link to comment
https://forums.phpfreaks.com/topic/69861-query/#findComment-351254
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.