Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. select distinct email, datetime
  2. from Log
  3. where email in (select email from tmp)
  4. group by email;
  5.  
  6. | email | datetime |
  7. +----------------------------+---------------------+
  8. | aaa@gmail.com | 2014-02-06 14:08:28 |
  9. | bbb@gmail.com | 2014-05-22 18:53:39 |
  10. | cc@gmail.com | 2014-05-22 18:51:19 |
  11. +----------------------------+---------------------+
  12.  
  13. select email, max(datetime )
  14. from Log
  15. where email in (select email from tmp)
  16. group by email;
  17.  
  18. select distinct email, max(datetime)
  19. from Log
  20. where email in (select email from tmp)
  21. group by email;
  22.  
  23. select distinct email, datetime
  24. from Log
  25. where email in (select email from tmp)
  26. group by email
  27. ORDER BY datetime desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement