Guest User

Untitled

a guest
Jun 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. id | page_id | user_id | session_id | created
  2.  
  3. SELECT a.session_id, MIN(a.created) as start_time,
  4. b.page_id AS last_page, b.end_time
  5. FROM table a
  6. INNER JOIN
  7. (SELECT b.session_id, MAX(b.created) as end_time, MAX(b.page_id)
  8. FROM table b GROUP BY b.session_id)
  9. ON a.session_id = b.session_id GROUP BY a.session_id
  10.  
  11. SELECT MIN(created), MAX(page_id)
  12. FROM modules
  13. GROUP BY
  14. session_id
Add Comment
Please, Sign In to add comment