Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Consulta MySQL, seleção, grupo e soma por minutos

SELECT 
  SUM(donation_amount) AS total_donation_amount,
  EXTRACT(YEAR from time_inserted) AS year,
  EXTRACT(MONTH from time_inserted) AS month,
  EXTRACT(DAY from time_inserted) AS day,
  EXTRACT(HOUR from time_inserted) AS hour,
  EXTRACT(MINUTE from time_inserted) AS minute
FROM `DONATION`
WHERE `time_inserted` > '2012-12-07 10:00:00' 
AND `donation_type` = 'em1'
GROUP BY year, month, day, hour, minute;