Guest User

Untitled

a guest
Dec 11th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. location
  2.  
  3. t1.username = t2.username AND t2.type != 3 AND t2.Location != null AND
  4. (t2.DateTime between t1.Datetime +15 min AND t1.Datetime -15)
  5.  
  6. UserName, Type, Location
  7.  
  8. SELECT
  9. id,
  10. username,
  11. type,
  12. COALESCE(location,
  13. CASE
  14. (SELECT id FROM table1 INNER JOIN table2 ON t1.username = t2.username WHERE t2.type != 3 AND t2.Location != null AND
  15. (t2.DateTime between t1.Datetime +15 min AND t1.Datetime -15))
  16. END) AS location,
  17. datetime
  18. FROM table_name
Add Comment
Please, Sign In to add comment