0

这返回2条记录,但是第二行总和显示为null,这是怎么回事?

SELECT nvl(X_CDTR_AGT_ID_2AND,' ')

      ,COUNT(CASE P_PMNT_SRC WHEN 'FDR_ATM' THEN 1 END) as atmCount

      ,( SELECT sum(X_STTLM_AMT) AS IVRSUM
           FROM v_minf_report b 
           WHERE b.X_CDTR_AGT_ID_2AND = ass.X_CDTR_AGT_ID_2AND  
           GROUP BY X_CDTR_AGT_ID_2AND ) as nyun

      ,COUNT(CASE P_PMNT_SRC WHEN 'FDR_INB' THEN 1 END) as inbCount
      ,COUNT(CASE P_PMNT_SRC WHEN 'FDR_IVR' THEN 1 END) as ivrCount
      ,COUNT(CASE P_PMNT_SRC WHEN 'FDR_BV' THEN 1 END) as bvcount
      ,COUNT(CASE P_PMNT_SRC WHEN 'FDR_MANUAL' THEN 1 END) as manualcount

FROM v_minf_report ass
WHERE P_TX_CTGY = 'CTO'
GROUP BY X_CDTR_AGT_ID_2AND
4

1 回答 1

0
SELECT
 X_CDTR_AGT_ID_2AND, atmCount, IVRSUM, inbCount, ivrCount, bvcount, manualcount
FROM (
 SELECT nvl(X_CDTR_AGT_ID_2AND,' ') X_CDTR_AGT_ID_2AND,
 COUNT(CASE P_PMNT_SRC WHEN 'FDR_ATM' THEN 1 END) as atmCount,
 COUNT(CASE P_PMNT_SRC WHEN 'FDR_INB' THEN 1 END) as inbCount,
 COUNT(CASE P_PMNT_SRC WHEN 'FDR_IVR' THEN 1 END) as ivrCount,
 COUNT(CASE P_PMNT_SRC WHEN 'FDR_BV' THEN 1 END) as bvcount,
 COUNT(CASE P_PMNT_SRC WHEN 'FDR_MANUAL' THEN 1 END) as manualcount
 FROM v_minf_report
 WHERE P_TX_CTGY = 'CTO'
 group by X_CDTR_AGT_ID_2AND
) as ass JOIN (
 SELECT nvl(X_CDTR_AGT_ID_2AND,' ') X_CDTR_AGT_ID_2AND,
 sum(X_STTLM_AMT) AS IVRSUM
 from v_minf_report 
 GROUP BY X_CDTR_AGT_ID_2AND
) as nyun USING(X_CDTR_AGT_ID_2AND)
于 2012-09-01T11:45:11.010 回答