I have a table in a MySQL database as below:
ID Timestamp State
1 2013-07-10 09:00:00 Good
1 2013-07-10 09:10:00 Good
1 2013-07-10 09:20:00 Good
1 2013-07-10 09:30:00 Bad
1 2013-07-10 09:40:00 Bad
1 2013-07-10 09:50:00 Bad
1 2013-07-10 10:00:00 Good
1 2013-07-10 10:10:00 Good
I want to generate a report as shown below using the above table.
ID Start Timestamp End Timestamp Duration(in mins) State
1 2013-07-10 09:00:00 2013-07-10 09:30:00 30 Good
1 2013-07-10 09:30:00 2013-07-10 10:00:00 30 Bad
1 2013-07-10 10:00:00 2013-07-10 10:10:00 10 Good
The query that I had generated is not able to showcase the switching taking place.
id = 1
?Timestamp
values unique? Or are they unique at least perID
?