Example queries
This page contains a number of example queries which can help you get started analyzing the data available via the Data Connector with SQL via AWS Athena.
All example queries reference a database when referring to tables. For example when querying the dim_user table, the query references the table as data-connector-1234.dim_user
.
This database reference is unique per customer so make sure to replace this with the name of your database. To find the name of your database, you can use the bucket name and remove the -production
reference at the end.
For example:
Bucket name:
data-connector-1234-production
Database name:
data-connector-1234
Get All Active Users
This query returns a list of all users that have gained XP in the last 7 days.
All users
This query returns a list of all users that are currently in your group.
Removed users
Please notice the deleted_at filter, if you leave this out the query will also return the users that have been in your group but have since been removed.
The data of these removed users cuts off at the moment they left your group. If they continued learning afterwards on their own terms or subscription, this data will not be available via the Data Connector.
Time spent per user
The Data Connector contains detailed information on where your users are spending their time learning.
Time-spent data is limited to the following content types: Courses, Practices and Projects.
Assessments, Workspace, Certification and other products are not included in these numbers!
Time spent per team
Similar to time per user, we can also aggregate time spent totals per team.
On team membership and scope
Keep in mind this only show the XP gained by the users currently in the respective team, this means once someone leaves a team, the team's XP will go down.
A single user can be member of multiple teams which means their XP will be essentially double-dipped into several team buckets. Keep this in mind as adding up these team-XP values won't add up to the total XP gained across all users.
If you want time_spent to remain allocated to the team, even if a user has left the team, you can use the user_team_bridge
table which has joined_team_date
& left_team_date
columns you can use to calculate the period of time the user was part of a team.
Time spent per technology
Another way of looking at time spent is by technology or topic. Each content type at DataCamp has an associated technology or topic, using these dimension tables combined with the fact tables we can get information on which technologies learners are spending most of their time.
In order to get these numbers per topic instead of technology, you can swap out the technology column from the fact tables with the topic column.
Completed assessments
This query gives you all complete assessments along with their user, score and percentile.
Completed courses by user
This query returns all courses that have been completed by users in your group. For this query it is important to understand that the course_fact
table contains multiple entries per user/course, this table essentially contains sessions the user learned in the respective course. For each of the sessions there is a time_spent and XP value associated, indicating how long the user learned and how much XP they gained doing so. Once the course is completed every record for that user/course will have it's completed_at
date set. Using this knowledge we can now query all completed courses by filtering on distinct course_id
and completed_at
values.
XP earned by user
This simple query sums up the total XP for users and decorates it with user data by joining the user_dim
table.
Last updated