SELECT
    DATE(pay_authdate) as Date,
    COUNT(pay_authdate) AS Qty,
    SUM(CASE WHEN pay_result = 'debit' THEN pay_amount ELSE 0 END) AS Debit_Sum,
    SUM(CASE WHEN pay_result = 'credit' THEN pay_amount ELSE 0 END) AS Credit_Sum
    FROM
        payment_log
WHERE
    YEAR(pay_authdate) = 2023 AND pay_result IN ('DEBIT','CREDIT')
GROUP BY
    DATE(pay_authdate)
ORDER BY
    DATE(pay_authdate) DESC