Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. -- Get user IDs for anyone who has enrolled in a course…
  2. select chu.userid, chu.created, ohu.organizationid
  3.  
  4. from
  5. course_has_user as chu
  6.  
  7. left join organization_has_user as ohu
  8. on ohu.userid = chu.userid
  9.  
  10. where
  11.  
  12. -- …in the last 7 days
  13. chu.created > DATEADD(day, -7, CURRENT_DATE)
  14.  
  15. -- …where the course was part of the UFB content subscription
  16. and chu.courseid in
  17. (
  18. select course_id
  19. from organization_categories_coursenode coursenode
  20. left join organization_categories_basenode basenode on basenode.id=coursenode.basenode_ptr_id
  21. where tree_id = (select tree_id
  22. from organization_categories_contentsubscriptionnode csn
  23. left join organization_categories_basenode bn on bn.id=csn.basenode_ptr_id
  24. where is_default=1)
  25. group by 1
  26. )
  27.  
  28. -- …and the user is not part of a UFB account
  29. and ohu.organizationid is null
  30.  
  31. order by created desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement