Created
December 22, 2015 16:27
-
-
Save hanleybrand/fb7919cea9c6fcaeadf8 to your computer and use it in GitHub Desktop.
Blackboard SQL query (bb_bb60 schema) for SQL SERVER (t-sql) -- retrieve enrollments in courses where @USER_ID (username) is an instructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use bb_bb60 | |
| declare @USER_ID varchar(8); | |
| set @USER_ID= 'username' | |
| SELECT | |
| distinct cm.COURSE_NAME | |
| , COUNT(cu.USERS_PK1) OVER (PARTITION BY cu.CRSMAIN_PK1) AS Num_students | |
| FROM COURSE_USERS cu | |
| join COURSE_MAIN cm on cu.CRSMAIN_PK1 = cm.PK1 | |
| where | |
| cu.CRSMAIN_PK1 in (select CRSMAIN_PK1 from COURSE_USERS cu where cu.USERS_PK1 = | |
| (select PK1 from USERS u where u.USER_ID = @USER_ID) | |
| and cu.ROLE = 'P') | |
| and cu.ROLE = 'S' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note - you may need to change the number of characters for the
declare @USER_ID varchar(8)statement depending on your installation's username implementation