Find TimeDiff using column information
===

 0 down vote favorite
	

I have a new problem now. I want to find time diff between row values when their value is changed. I have the following similar data in my table, For ex:

    ------------------------------------
        DateandTime     |    DCStatus
    ------------------------------------
    2012-01-01 01:00:00 |    Using 
    2012-01-02 02:00:00 |    Using
    2012-01-03 03:00:00 |    Using
    2012-01-04 04:00:00 |    Charging
    2012-01-05 05:00:00 |    Charging
    2012-01-06 06:00:00 |    Using
    ------------------------------------

Here when the DCStatus changes from Using to Charging means the battery is dead and it has gone to charging mode. So the timediff between the 1st value and then changed value would give me the life of the battery and when the mode changes back to Using would give me charging time. So average of these values would give me Avg Charging time and Avg discharge time and I also want to output how many times this is done. I have tried several ways but couldn't figure it out. I am a newbie to MySQL and Database Programming. Thank You in Advance for your help.
