DROP table if exists day_stats;

Create table day_stats as
SELECT 
    count(instance_id) as i
  , sum(users) as u
  , sum(local_events) as e
  , sum(local_groups) as g
  , insertedAt  as x
  , insertedAt / (3600*24) as j
FROM stats
GROUP BY j
