leading-project/dw/dim/dim_project_base_info_d.sql

26 lines
1.0 KiB
MySQL
Raw Normal View History

2024-07-21 22:06:45 +08:00
SELECT
c.CommId,
c.ManageKind,
case when c.ManageKind = '0001' then '项目内盘'
when c.ManageKind = '0002' then '项目外盘(全委)'
when c.ManageKind = '0003' then '项目外盘(合资)'
when c.ManageKind = '0004' then '案场内盘'
when c.ManageKind = '0005' then '案场外盘(全委)'
when c.ManageKind = '0006' then '案场外盘(合资)'
end ManageKindName,
I.ContractArea,
I.ManageContractArea,
COALESCE((
SELECT SUM(COALESCE(TakeOverArea, 0))
FROM ods_erp_tb_hspr_projecttakeoverdetail_d
WHERE IsDelete = 0 AND ParentId = I.ID
), 0) AS TakeOverArea
, right(b.StateName,4) StateName
, b.Province
, b.City
, b.County
FROM ods_erp_tb_hspr_projecttakeoverinformation_d AS I
right join ods_erp_tb_hspr_projectbasicinfomation_d b
on i.ParentId = b.id
right join ods_erp_tb_hspr_community_d c
on b.CommId = c.CommId