Hi Guys,
I am trying to extract minimum maximum time from active terminal until it changes the ownership.
The input as per below.
As you can see there is terminal id can change the ownership with the change_flag = 1, if the change_flag = 0 means same ownership from previous record.
I would like to get entire length of duration from the same owner as per below output:
Thanks alot in advance
I am trying to extract minimum maximum time from active terminal until it changes the ownership.
The input as per below.
Code:
TERMINAL_ID TERMINAL_NAME START_DATE END_DATE CHANGE_FLAG
1128565 JAPANPOST BANK(705910) OKINAWA JP 1/05/2016 31/12/2016 1
1128565 JAPANPOST BANK(003500) TOKYO JP 1/01/2017 30/06/2017 0
1128565 JAPAN RAMEN 1/07/2017 31/08/2017 1
4184558 POST Diamond Creek F VicAU 1/05/2016 31/10/2016 1
4184558 BRIDGE CLINIC MURRAY BRIDGESA AU 1/05/2017 30/06/2017 1
As you can see there is terminal id can change the ownership with the change_flag = 1, if the change_flag = 0 means same ownership from previous record.
I would like to get entire length of duration from the same owner as per below output:
Code:
TERMINAL_ID TERMINAL_NAME START_DATE END_DATE CHANGE_FLAG
1128565 JAPANPOST BANK(705910) OKINAWA JP 1/05/2016 30/06/2017 1
1128565 JAPAN RAMEN 1/07/2017 31/08/2017 1
4184558 POST Diamond Creek F VicAU 1/05/2016 31/10/2016 1
4184558 BRIDGE CLINIC MURRAY BRIDGESA AU 1/05/2017 30/06/2017 1
Thanks alot in advance