Update target table

Database

Update target table

I am trying to update the target table from the source table for the disruption column. When there is a disruption, the column should update with a 'Y', if not, then it should update with a 'N'.

In the source table for account 300815,

Service started on 1/15/2014 for City, Channel, Street

Removed City and Channel on 4/25/14

Added Channel back on 1/6/15.

This is a disruption of service for Channel because the customer removed Channel on 4/25/14 and added Channel back on 1/6/15.

Here is the data:


SOURCE TABLE

ACCOUNT  START_DT     END_DT AREA_NAME
300815 1/15/2014 4/23/2014 CHANNEL
300815 1/15/2014 4/24/2014 CHANNEL
300815 1/15/2014 12/31/9999 STREET
300815 1/15/2014 4/24/2014 CITY
300815 4/24/2014 4/24/2014 CHANNEL
300815 12/31/2014 1/5/2015 CHANNEL
300815 12/31/2014 12/31/9999 CHANNEL
400578 1/15/2014 4/23/2014 CHANNEL
400578 1/15/2014 5/10/2014 STREET
400578 4/24/2014 5/10/2014 CHANNEL
500187 12/15/2014 12/31/9999 CHANNEL
500187 12/15/2014 12/31/9999 CHANNEL
500187 12/15/2014 12/31/9999 STREET

TARGET TABLE

ACCOUNT AREA_NUMBER AREA_NAME  START_DT ANNIVERSARY_DATE AREA_STATUS ACTIVE DISRUPTION
300815 2180 CITY 1/15/2014 1/15/2015 Inactive N ?
300815 2179 STREET 1/15/2014 1/15/2015 Active Y ?
300815 2181 STREET 1/15/2014 1/15/2015 Active Y ?
300815 2178 CHANNEL 1/15/2014 1/15/2015 Active Y ?
400578 2179 STREET 1/15/2014 1/15/2015 Inactive N ?
400578 2178 CHANNEL 1/15/2014 1/15/2015 Inactive N ?
500187 2178 HSD 12/15/2014 12/15/2015 Active Y ?
500187 2179 Video 12/15/2014 12/15/2015 Active Y ?

RESULTS AFTER UPDATE

ACCOUNT AREA_NUMBER AREA_NAME  START_DT ANNIVERSARY_DATE AREA_STATUS ACTIVE DISRUPTION
300815 2180 CITY 1/15/2014 1/15/2015 Inactive N N
300815 2179 STREET 1/15/2014 1/15/2015 Active Y N
300815 2181 STREET 1/15/2014 1/15/2015 Active Y N
300815 2178 CHANNEL 1/15/2014 1/15/2015 Active Y Y
400578 2179 STREET 1/15/2014 1/15/2015 Inactive N N
400578 2178 CHANNEL 1/15/2014 1/15/2015 Inactive N Y
500187 2178 HSD 12/15/2014 12/15/2015 Active Y N
500187 2179 Video 12/15/2014 12/15/2015 Active Y N