...
Code Block | ||
---|---|---|
| ||
SELECT count COUNT(*) as "CountResolved Disputes", sumSUM(d.disputeamountamount) as "Total Dispute Amount", COUNT_IF(d.losstotal < 0) as "Disputes With Losses", sum SUM(d.losstotal * -1) as "Total Loss Amount", sum COUNT_IF(d.merchanttotal < 0) as "Disputes With Recovery", SUM(d.merchanttotal * -1) as "Total Recovered Amount", COUNT_IF(d.denyreason = 'Merchant Issued Credit' AND (d.amount + d.merchanttotal + d.losstotal) > 0) as "Disputes With Merchant Credit", SUM(CASE WHEN (d.denyreason = 'Merchant Issued Credit' AND (d.amount + d.merchanttotal + d.losstotal) > 0) THEN d.amount + d.merchanttotal + d.losstotal END) as "Total Merchant Credits" FROM dispute AS d JOIN claim AS c ON c.tenantid = d.tenantid AND c.claimid = d.claimid WHERE d.resolveddatetime =:daterange AND d.status in ('Resolved-Paid', 'Resolved-Denied') -- exclude open disputes and temporary authorizations that posted as these will have a new dispute record |
...