I need help or idea how to write it, a mysql statement. I need to select a row when a specific column changes its value. Rows after that with the same value should not be selected. For example we have a table like this, populate with this values:
ID status_1 status_2 status_3 timestamp
1 0 0 0 2016-01-01 00:00:00
2 0 0 1 2016-01-01 01:00:00
3 0 1 0 2016-01-01 02:00:00
4 0 1 1 2016-01-01 03:00:00
5 1 0 0 2016-01-01 04:00:00
6 1 0 1 2016-01-01 05:00:00
7 1 1 0 2016-01-01 06:00:00
8 1 1 1 2016-01-01 07:00:00
If i wanna select the rows when the status_1 change, the query should select the rows with ID 1 AND 5, if i am working with status_2 rows with IDs: 1, 3, 5, 7, and if i am working with status_3 all IDs. Hope someone can help me with all the times in the past.
Thanks in advance