Guest User

Untitled

a guest
Jun 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.72 KB | None | 0 0
  1. SELECT count(id),created FROM event
  2. WHERE created > now() - interval 1 day
  3. AND type = 'name_of_action'
  4. AND user = 'username'
  5.  
  6. union
  7.  
  8. SELECT count(id),created FROM event
  9. WHERE created > now() - interval 2 day and interval 1 day
  10. AND action = 'name_of_action'
  11. AND user = 'username'
  12.  
  13. /*
  14. Trying to have a query that will go and give me the count of unique id's that have a certain action against them. But the kicker is that I want it to give me the count by each day. not by each 24 hour interval from the moment I run it but what the count is for the actual calendar date.
  15.  
  16. Ex. If i run the query at 8 am on 2012-02-08 i should only have the unique count for the last 8 hours, not all the way back to 8 am on 2012-02-07
  17.  
  18. */
Add Comment
Please, Sign In to add comment