32 lines
1.4 KiB
SQL
32 lines
1.4 KiB
SQL
with one_to_many AS(
|
|
SELECT
|
|
a.username AS username -- 用户名
|
|
,SUBSTRING_INDEX(SUBSTRING_INDEX(a.mang_project, ',',b.help_topic_id + 1),',',-1) AS mang_project -- 管理项目名
|
|
FROM ods_one_to_many_perm a
|
|
JOIN mysql.help_topic b
|
|
on b.help_topic_id < (LENGTH(a.mang_project) - length(replace(a.mang_project,',','')) + 1)
|
|
WHERE a.username = '${fine_username}'
|
|
)
|
|
SELECT
|
|
organ_code -- erp片区code
|
|
,organ_name -- erp片区名称
|
|
,comm_id -- 项目id
|
|
,comm_name -- 项目名称
|
|
,index_income_target -- 收入目标
|
|
,index_income_fact -- 收入完成
|
|
,income_completion_rate -- 完成率
|
|
,index_cost_target -- 成本目标
|
|
,index_cost_fact -- 成本完成
|
|
,cost_completion_rate -- 完成率
|
|
,index_profit_target -- 利润目标
|
|
,index_profit_fact -- 利润完成
|
|
,profit_completion_rate -- 完成率
|
|
,index_market_target -- 市扩目标
|
|
,index_market_fact -- 市扩完成
|
|
,market_completion_rate -- 完成率
|
|
from ods_caiwu_feecollection
|
|
where category = '物业'
|
|
and index_profit_fact < 0
|
|
${IF(LEN(p_startdate)>0," AND yr_month ='" + p_startdate + "'","and yr_month = '2024-06' ")}
|
|
${if(len(p_area) == 0,"","and organ_code in ('" + p_area + "')")}
|
|
${IF(LEN(p_shop)!=0," and comm_name IN ('"+JOINARRAY(p_shop,"','")+"')","")} |