Guest User

Untitled

a guest
Jul 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. URL: google.com youtube.com google.com youtube.com test.com youtube.com
  2. DateVisited: 1313668492 1313668540 1313668571 13154314
  3.  
  4. LINK | timesExisted | timesVisitedYesterday
  5. Google.com | 2 | 2
  6. youtube.com| 3 | 3
  7.  
  8. subdate(current_date, 1)
  9.  
  10. SELECT
  11. url as LINK,
  12. count(*) as timesExisted,
  13. sum(DateVisited between UNIX_TIMESTAMP(subdate(current_date, 1)) and
  14. UNIX_TIMESTAMP(current_date)) as timesVisitedYesterday
  15. FROM mytable
  16. GROUP BY 1;
  17.  
  18. SELECT * FROM your_table
  19.  
  20. WHERE DateVisited >= UNIX_TIMESTAMP(CAST(NOW() - INTERVAL 1 DAY AS DATE))
  21. AND DateVisited <= UNIX_TIMESTAMP(CAST(NOW() AS DATE));
  22.  
  23. ('2012-02-27' - INTERVAL 1 DAY)
Add Comment
Please, Sign In to add comment