i'm using mysql,
my table looks like this:
id date command number
1 20020528123713 1 0191011
2 20020528123843 0
3 20020528124747 1 0191011
4 20020528125040 0
5 20020528125252 1 0191011
6 20020528125446 0
...
it is used to track the connections to my internet service provider
if there is a 1 in the command field it means, that my isdn4l diald the number and a connection to the isp was established at date
the 0 in the command field means that the connection was terminated at date. (date means the value of the date field - a timestamp)
what i need is a query that gives a table with the connection time...
therefor it has to calculate the difference of the date fields between a line whith command=1 and the next line with command=0
that means for the example at the beginning of this text:
my-sql> my_searched_query;
returns:
id dialtime uptime
1 20020528123713 (20020528123713-20020528123843)
2 20020528124747 (20020528124747-20020528125040)
3 20020528125252 (20020528125252-20020528125446)
where values in () means that this operation has to calculated...
that's it, hope now you can imagine what i would like to have...