dimanche 8 mars 2015

sql sum of date differences

i am developing an android application which has a table named "entries" the table structure is as follows



id name operation date
----------------------------------------------
1 engine on 08-03-2015 19.22
2 engine off 08-03-2015 19.23
3 light on 08-03-2015 19.23
4 light off 08-03-2015 19.28
5 engine on 08-03-2015 19.28
6 engine off 08-03-2015 19.30


i woul like to get the output as follows



name duration
----------------
engine 3
light 5


That is the total time on which the engine and light if in on state. In detail for engine the time difference b/w on and off state are added and taken as output.similarly for light. Anyone plz help me Dont know how to start. Thanks in advance


Aucun commentaire:

Enregistrer un commentaire