fetching next record based on previous record

Teradata Applications
Teradata Employee

fetching next record based on previous record

Hi ,

 

I have the below data in a table PEDW.LEG_SCHEDULED_SSIM

 

onward_leg_id,    leg_id,  date                time       flight_sequence

123                        456     2015/01/25     01:30     1

789                        254     2015/01/25     05:30      2

777                       123      2015/01/25     04:30       2

265                        123     2015/01/26     13:00       2

589                        777      2015/01/25     12:00     3

 

 

Below is the expected result based on onward_leg_id  which matches next leg id ,and date i want to populate next row and chucking out remaining records :

onward_leg_id,    leg_id,  date                time      flight_sequence

123                        456     2015/01/25     01:30    1

777                       123      2015/01/25     04:30    2

589                        777      2015/01/25     12:00   3

 

1 REPLY
Junior Contributor

Re: fetching next record based on previous record

Sorry, but there's no way to know why you want this result, you need to explain the logic in detail.