Re: Grouping based on state changes

2004-09-22 Thread SGreen
I think all you need is a GROUP BY. Here is a tutorial sample from the manual: http://dev.mysql.com/doc/mysql/en/Counting_rows.html Here is page that describes the full SELECT syntax, including GROUP BY http://dev.mysql.com/doc/mysql/en/SELECT.html And here are all of the other functions you can

Re: Grouping based on state changes

2004-09-22 Thread Michael Stassen
Use GROUP BY: SELECT state, AVG(value) FROM yourtable GROUP BY state; See the manual for all the details . Michael [EMAIL PROTECTED] wrote: I have the following table definition for time series data: ID (int) time (DATETIME)sta

Grouping based on state changes

2004-09-22 Thread mads
I have the following table definition for time series data: ID (int) time (DATETIME)state (int)value (int) I want to make a state based grouping and calculate the mean of each grouping. The state based grouping should be done by creating a new group whenever the state changes, from