SELECT hash, addr, FROM_UNIXTIME(TRUNCATE( UNIX_TIMESTAMP( created_at )/86400, 0 ) * 86400 ) as h, sum( amount ) as amount, COUNT(*) as q FROM transactions WHERE contract = '***' AND created_at between '2019-02-06' AND '2019-04-06' GROUP BY h ORDER BY h asc;