-- 【dic_项目】

SELECT DISTINCT
    project_id AS 项目id,
    project_name AS 项目名称
FROM dws_business_rent_rate_d
WHERE 1=1
    ${IF(LEN(p_type)>0,"AND type IN ('"+JOINARRAY(p_type,"','")+"')","")}


-- 【dic_业态】

SELECT DISTINCT
    type AS 业态
FROM dws_business_rent_rate_d


-- 【report_1_指标卡】

SELECT
    project_name AS 项目,
    COUNT(project_id) AS 资产数量,
    SUM(IFNULL(construction_area,0)) AS 资产面积,
    SUM(IFNULL(lease_area,0)) AS 已出租面积
FROM dws_business_rent_rate_d T1
WHERE 1=1
    ${IF(LEN(p_startdate)>0,"AND T1.lease_start_date <= '"+FORMAT(p_startdate,"yyyy-MM-dd 00:00:00")+"'","")}
      ${IF(LEN(p_enddate)>0,"AND T1.lease_end_date >= '"+FORMAT(p_enddate,"yyyy-MM-dd 00:00:00")+"'","")}
      ${IF(LEN(p_type)>0," AND T1.type IN ('"+JOINARRAY(p_type,"','")+"')", "")}
      ${IF(LEN(p_project)>0," AND T1.project_id IN ('"+JOINARRAY(p_project,"','")+"')", "")}
GROUP BY project_name