where条件的内容就是判断chanye 和chanpinxian 这俩单选框里面有没有值,如果有值的话,就让F_MKMC = chanye,F_CPXMC = chanpinxian这样写的话读取不到参数,改成$又只能读取到chanye${if(
a = "1",
if(
len(quyu) == 0 || quyu = "集团",
"
SELECT f_gjgsmc,F_ZGSMC,
sum(应收账款) 应收账款,
sum(未开票应收) 未开票应收,
sum(已开票应收) as 已开票应收,
sum(超期应收) 超期应收,
sum(超期未开票) 超期未开票
from(
(
SELECT f_gjgsmc,F_ZGSMC,F_MKMC,F_CPXMC,
SUM(f_ysje) / 10000 as 应收账款,
SUM(f_wkpje) / 10000 as 未开票应收,
(sum(f_kphsje) - sum(f_hkje)) / 10000 as 已开票应收,
NULL as 超期应收,
NULL as 超期未开票
FROM dwd_db.dwd_pulianyszk
WHERE LENGTH(f_srrq) >= 8
AND f_gjgsmc IS NOT NULL
AND f_gjgsmc != ' ' and F_GJGS in ('10001','10002','10003','10004')
GROUP BY f_gjgsmc,F_ZGSMC,F_MKMC,F_CPXMC
)
UNION ALL
(
SELECT f_gjgsmc,F_ZGSMC,F_MKMC,F_CPXMC,
NULL as 应收账款,
NULL as 未开票应收,
NULL as 已开票应收,
SUM(f_ysje) / 10000 as 超期应收,
SUM(f_wkpje) / 10000 as 超期未开票
FROM dwd_db.dwd_pulianyszk
WHERE LENGTH(f_srrq) >= 8
AND (CURRENT_DATE - f_srrq::date) > f_yjbz
AND f_gjgsmc IS NOT NULL
AND f_gjgsmc != ' ' and F_GJGS in ('10001','10002','10003','10004')
GROUP BY f_gjgsmc,F_ZGSMC,F_MKMC,F_CPXMC
)
)
GROUP BY f_gjgsmc,F_ZGSMC
order by f_gjgsmc,F_ZGSMC
",
""
),
if(
a = "2",
"",
""
)
) }