Mysql
 sql >> Database >  >> RDS >> Mysql

GROUP BY solo le righe con una determinata condizione e data

provalo,

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