sql >> Base de Datos >  >> RDS >> Mysql

AGRUPAR POR solo filas con una determinada condición y fecha

pruébalo,

SELECT  transaction_date, transaction_type, SUM(transaction_amount)
FROM    TableName
-- WHERE customer_id = $customer_id
GROUP   BY transaction_date, 
           CASE WHEN transaction_type = 'refund' THEN 1 ELSE RAND() END
ORDER   BY transaction_date DESC