I have this below query that pulls data from 1 single table:
SELECT LOAD_ID, STOP_NUM, LOCATION_ID, MILES, MILES_INDICATOR
WHERE OPEN_TIME > TO_DATE (TO_CHAR (SYSDATE, 'YYYYMMDD'), 'YYYYMMDD') - 7
ORDER BY LOAD_ID, STOP_NUM;
What i'm trying to do is to find every MILES_INDICATOR that equals '4' and then, it will take the LOCATION_ID of the same row as the FROM value, then take the LOCATION_ID of the following row as the TO value.
The data must be sorted as : ORDER BY LOAD_ID, STOP_NUM
How can i do that?
In the attachment, you will see 2 sheets:
1- Table extract
= an example of the data in the table: LOAD_STOP
2- Final result
= what i would like to see as the final result from the query
Thanks again for your help.