select
    c.project_id
     , c.project_name
     , c.`type`
     , b.lease_start_date
     , b.lease_end_date
     , a.construction_area
     , b.lease_area
     , a.id room_id
from dim_business_room_d a
         left join (
    select
        a.id , a.contract_id, a.room_id , a.lease_area, b.lease_start_date, b.lease_end_date
    from dwd_business_leased_property_d a
             inner join (
        select id, lease_start_date, ifnull(stop_date, lease_end_date) lease_end_date, status, contract_type_code
        from dwd_business_contract_info_d
        where status != 0 and contract_type_code != 0201
    ) b
                        on a.contract_id = b.id
) b
                   on a.id = b.room_id
         left join (
    select
        id
         , project_id
         , project_name
         , `type`
    from dim_business_building_d
) c
                   on a.building_id = c.id