hi,
I have the fields like this
Name| status|timestamp
The status can be 0 or 1.
I have to find the timestamp difference between the status when it changes from 0 to 1.
here I have to find the difference of timestamp
master | 2008-03-24 09:10:02 | 0 |
| cluster | 2008-03-24 09:20:01 | 0 |
| master| 2008-03-24 09:20:01 | 1 |
| cluster | 2008-03-24 09:30:01 | 0 |
| master | 2008-03-24 09:30:01 | 1 |
| cluster | 2008-03-24 09:40:01 | 0 |
| cluster | 2008-03-24 09:50:02 | 0 |
| cluster | 2008-03-24 10:00:01 | 1 |
| cluster | 2008-03-24 10:10:01 | 0 |
| cluster | 2008-03-24 10:20:01 | 0 |
| cluster | 2008-03-24 10:30:01 | 0 |
| cluster | 2008-03-24 10:40:01 | 1 |
| cluster | 2008-03-24 10:50:01 | 0 |
| cluster | 2008-03-24 11:00:01 | 0 |
| cluster | 2008-03-24 11:10:01 | 0 |
| cluster | 2008-03-24 11:20:02 | 0 |
| cluster | 2008-03-24 11:30:02 | 1 |
| cluster | 2008-03-24 11:40:01 | 0 |
| cluster | 2008-03-24 11:50:02 | 0 |
| cluster | 2008-03-24 12:00:01 | 0 |
| master | 2008-03-24 12:00:01 | 0 |
| cluster | 2008-03-24 12:10:01 | 0 |
| master | 2008-03-24 12:10:01 | 0|
| cluster | 2008-03-24 12:20:01 | 0 |
| master | 2008-03-24 12:20:01 | 1 |
This is the result got from database.
When I print the difference I get the result for all the rows. I have to get only when status changes. For example the timestamp is at 2008-03-24 12:00:01 is 0 and name is master I should not calculate the difference of 2008-03-24 12:10:01 .
I have to directly calculate the differnce from 2008-03-24 12:00:01 to 2008-03-24 12:20:01 .
How to avoid the in between rows which has the status as 0.
Please help me with this