select ${IF(LEN($AREA)>0,"地市,","")}${IF(LEN($XMFL)>0,"项目类,","")}SUM(case when 周期='1' then else 0 end) as ,SUM(case when 周期='2' then else 0 end) as ,SUM(case when 周期='3' then else 0 end) as ,SUM(case when 周期='4' then else 0 end) as ,SUM(case when 周期='5' then else 0 end) as ,SUM(case when 周期='6' then else 0 end) as ,(select SUM(case when <> '未核销收款' then 本币余额 else 0 end) as from 应收预收账龄余额表 B where left(,4)='1131' and 来源='应收账款' and 日期='2023-02-23' AND A.地市=B.地市 AND A.项目类=B.项目段 ) as bbye, (SELECT SUM(case when <> '未知' then 期末余额 else 0 end) as from 账户组合余额表 C where 会计要素='收入' and 日期='2023-02-22' and 地市<>'未知' AND A.地市=C.地市 AND A.项目类=C.项目类 ) as qmye from A WHERE 日期='2023-02-21' ${IF(LEN(AREA)>0," AND 地市 in ('"+AREA+"')","")} ${IF(LEN(XMFL)>0," AND 项目类 in ('"+XMFL+"')","")} ${IF(LEN(XMFL)>0&&LEN(AREA)>0," group by 地市,项目类","")} ${IF(LEN(XMFL)>0&&LEN(AREA)=0," group by 项目类","")} ${IF(LEN(XMFL)=0&&LEN(AREA)>0," group by 地市","")}