diff --git a/dw/dim/dim_project_base_info_d.sql b/dw/dim/dim_project_base_info_d.sql index 1176e4a..8bfb4a2 100644 --- a/dw/dim/dim_project_base_info_d.sql +++ b/dw/dim/dim_project_base_info_d.sql @@ -1,3 +1,8 @@ +-- ***************************** +-- 修改人: 杨坤安 +-- 修改日期: 2024-09-06 +-- 修改内容: 一个项目接管面积会有多个,先累加再关联 +-- ***************************** select b.CommId , case when b.CommKind = '0001' then '商住' @@ -90,8 +95,23 @@ from ( , sum(TakeOverArea) TakeOverArea , sum(ContractArea) ContractArea , sum(ManageContractArea) ManageContractArea - from (select * from ods_erp_tb_hspr_projecttakeoverinformation_d where IsDelete = 0) a - left join (select TakeOverArea, ParentId from ods_erp_tb_hspr_projecttakeoverdetail_d WHERE IsDelete = 0) b + from + ( + select + * + from ods_erp_tb_hspr_projecttakeoverinformation_d + where IsDelete = 0 + ) a + left join + ( + select + ParentId + ,SUM(TakeOverArea) AS TakeOverArea + from ods_erp_tb_hspr_projecttakeoverdetail_d + WHERE IsDelete = 0 + group by + ParentId + ) b on a.id = b.ParentId right join (select * from ods_erp_tb_hspr_projectbasicinfomation_d where IsDelete = 0) c on a.ParentId = c.id