guys I have the following conflict:
I have the following SQL statement
SELECT SUM(monto) AS 'total',
SUM(CASE WHEN status_pago = 'PENDIENTE' THEN 1 ELSE 0 END) AS 'pendiente',
SUM(CASE WHEN status_pago = 'APROBADO' THEN 1 ELSE 0 END) AS 'aprobado'
FROM pagos
It gives me the following result:
and I would like to have additionally a value of the sum of the amounts where the status is equal to approved and logically in the sentence I have I can not place that condition with a WHERE because it would alter the result of number of rows with status pending.