From 7d3844d049334a38ec8339da699154d0c7002703 Mon Sep 17 00:00:00 2001 From: yangkunan Date: Fri, 6 Sep 2024 10:44:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9F=BA=E7=A1=80=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=90=88=E5=90=8C=E9=9D=A2=E7=A7=AF=E5=8F=96=E5=80=BC?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dw/dim/dim_project_base_info_d.sql | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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