SELECT TOP 1
    --Э鵥λʶ,ؿ, Ƿ
    ISNULL((SELECT SUM(ConsumeRMB) FROM ys_AgreementUnit_Account WHERE C_D='D' And ItemCode='KFGZ' AND AccountDate=##BEGIN),0) AS GZ_ConsumeRMB,
    ISNULL((SELECT SUM(PayRMB) FROM ys_AgreementUnit_Account WHERE C_D='C' And ItemCode='KFGZ' AND AccountDate=##BEGIN),0) AS GZ_PayRMB,
    ISNULL((SELECT SUM(ConsumeRMB) - SUM(PayRMB) FROM ys_AgreementUnit_Account WHERE AccountDate<=##BEGIN And ItemCode='KFGZ') ,0) AS GZ_Balance
FROM xt_WBM