Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get user IDs for anyone who has enrolled in a course…
- select chu.userid, chu.created, ohu.organizationid
- from
- course_has_user as chu
- left join organization_has_user as ohu
- on ohu.userid = chu.userid
- where
- -- …in the last 7 days
- chu.created > DATEADD(day, -7, CURRENT_DATE)
- -- …where the course was part of the UFB content subscription
- and chu.courseid in
- (
- select course_id
- from organization_categories_coursenode coursenode
- left join organization_categories_basenode basenode on basenode.id=coursenode.basenode_ptr_id
- where tree_id = (select tree_id
- from organization_categories_contentsubscriptionnode csn
- left join organization_categories_basenode bn on bn.id=csn.basenode_ptr_id
- where is_default=1)
- group by 1
- )
- -- …and the user is not part of a UFB account
- and ohu.organizationid is null
- order by created desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement