Mysql
 sql >> Base de données >  >> RDS >> Mysql

GROUP BY uniquement les lignes avec une certaine condition et date

essayez ceci,

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