I’m using SQL Developer for Oracle 11g..
I need to be able to loop through a set of dates,
check to see if the date above or below is = or < or >..
Then assign a trip number that is the same as the one its = to or
assign a new trip number and then begin a new trip and check again
the next date to see if its = or < or > than the current date..
I think in order to do this I need to use the pl/sql cursor for loop..
I’ve tried to figure it out but its not making much sense to me..
For example, I want the end result to be something like this..
ROWID DATE TRIP
1 1-Jan-12 1
2 2-Jan-12 2
3 2-Jan-12 2
4 3-Jan-12 3
5 4-Jan-12 4
6 1-Jan-12 1
7 4-Jan-12 4
Thanks in advance for your help.
Alex
You don’t need to loop at all! All you need is the analytic function dense_rank: