-- 【出租率】


SELECT
    `type`
     , sum(lease_area)/sum(construction_area) rent_rate
FROM dws_business_rent_rate_d
         ${if(len(project) == 0,"","where project_id in (" + project + ")")}
group by `type`



-- 【出租面积】

SELECT
    project_id
     , project_name
     , `type`
     , construction_area/10000 construction_area  -- 建筑面积
     , lease_area/10000 lease_area
     , lease_area/construction_area rent_rate

SELECT
sum(lease_area ) as lease_area  -- 出租面积
,sum(construction_area) as construction_area -- 建筑面积
, sum(lease_area ) / sum(construction_area) as rate
FROM dw.dws_business_rent_rate_d
where   lease_end_date >= '2024-07-25'  -- 合同结束时间
  and  lease_start_date <= '2024-07-25'

;




${if(len(project) == 0,"","where project_id in (" + project + ")")}

;
-- 出租率计算:  sum(出租面积.select(lease_area))/sum(出租面积.select(construction_area))    -- 正确值： 33.45%



-- 【收款金额】
SELECT
 sum(received_money)    实收金额
,sum(current_sure_money) 收款金额
,sum(received_money) / sum(current_sure_money) rate

,sum(areare_money) as areare_money
,sum(current_sure_money) as current_sure_money

,sum(areare_money) / sum(current_sure_money) as rate1
FROM
(
SELECT
    project_id
     , project_name
     , accrual_month
     , current_sure_money/10000 current_sure_money   -- 收款金额  收款金额
     , received_money/10000 received_money          -- 实收金额
     , areare_money/10000 areare_money              -- 欠收金额
FROM dws_business_bill_m
where left(accrual_month,7) = '2024-06'
 --    ${if(len(project) == 0,"","and project_id in (" + project + ")")}
    )T

-- 收缴率   64.8  截至 24

 --   sum(收款金额.select(received_money))/sum(收款金额.select(current_sure_money))

-- 欠缴 / 应缴