Create table t1 (traceid number, objectid number, locationid number, time number)
insertinto t1 values(1,1,1,1)
insertinto t1 values(2,1,1,2)
insertinto t1 values(3,1,2,4)
insertinto t1 values(4,1,2,6)
insertinto t1 values(5,1,3,9)
insertinto t1 values(6,2,1,3)
insertinto t1 values(7,2,1,5)
insertinto t1 values(8,2,3,8)
The timein of an object at a location is min(time) of the object at the location and timeout is min(time) of the object in next location.
I need sql which can fetch the records as the following:
(ObjectID, FromLocationId,ToLocationID, timein, timeout)
(1, 1, 2, 1, 4)
(1, 2, 3, 4, 9)
(2, 1, 3, 3, 8)
insertinto t1 values(1,1,1,1)
insertinto t1 values(2,1,1,2)
insertinto t1 values(3,1,2,4)
insertinto t1 values(4,1,2,6)
insertinto t1 values(5,1,3,9)
insertinto t1 values(6,2,1,3)
insertinto t1 values(7,2,1,5)
insertinto t1 values(8,2,3,8)
The timein of an object at a location is min(time) of the object at the location and timeout is min(time) of the object in next location.
I need sql which can fetch the records as the following:
(ObjectID, FromLocationId,ToLocationID, timein, timeout)
(1, 1, 2, 1, 4)
(1, 2, 3, 4, 9)
(2, 1, 3, 3, 8)