leading-project/finereport/kanban/pc/商业.sql

73 lines
2.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ---------------------
-- 【出租率】
-- ---------------------
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%
-- 业务反馈 建筑面积 335335.36
-- 租赁面积: 298452.2
-- 出租率: 0.890011122000376
-- ============================================================================================================
-- ------------------------------
-- 【收款金额】
-- -------------------------------
SELECT
sum(received_money)
,sum(current_sure_money)
,sum(received_money) / sum(current_sure_money) rate
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))
-- 欠缴 / 应缴