I have a table with the columns car_id, stop_location, arrive_time and leave_time. I'd like to add a column stop_sequence, which would start at 1 and increment by 1 for each row with the same car_id and then start again at 1 for the next car_id (when ordered by car_id, arrive_time).
It should look like this:
car_id stop_lcn arr_time leave_time stop_sequence
A Home -- 0900 1
A Shop 1000 1100 2
A Work 1130 1700 3
B Home -- -- 1
C Home -- 0900 1
C School 0930 1600 2
If anybody can tell me how I would go about adding this extra column I'd greatly appreciate the help!