-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse-access.sql
34 lines (33 loc) · 1012 Bytes
/
course-access.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Course access via browser and Pulse app (one row each day that student accesses course per source) */
SELECT
access.orgunitid,
users.username,
users.firstname,
users.lastname,
access.dayaccessed,
access.source
FROM (
SELECT
orgunitid,
userid,
DATE(PARSE_DATETIME(dayaccessed, 'yyyy-MM-dd HH:mm:ss.SSS z')) AS dayaccessed,
'Browser' AS source
FROM
brightspace_data_sets_[your_schema_id].courseaccess_9_9_3
WHERE
dayaccessed IS NOT NULL
UNION
SELECT DISTINCT
orgunitid,
userid,
DATE(PARSE_DATETIME(timestamp, 'yyyy-MM-dd HH:mm:ss.SSS z') AT TIME ZONE 'UTC' AT TIME ZONE 'America/New_York') AS dayaccessed,
source
FROM
brightspace_data_sets_[your_schema_id].courseaccesslog_9_9_3
WHERE
timestamp IS NOT NULL
) AS access
JOIN brightspace_data_sets_[your_schema_id].users_9_9_3 AS users
ON access.userid = users.userid
WHERE access.orgunitid = 1234567 /* optional filter for specific course */
ORDER BY users.lastname, access.dayaccessed