leading-project/dw/dws/dws_business_rent_rate_d.sql

31 lines
897 B
MySQL
Raw Normal View History

2024-07-21 22:06:45 +08:00
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