This query fetches the courses that are the most played freely from the catalog (result in descending order by number of plays where the context is free, i.e. not within a path)

Query

select
    trackings.course as course_id,
    courses.name as course_name,
    count(distinct trackings.user) as nb_learners
from qwnogpy_ww21770_datasharing.core.courses_trackings trackings
left join qwnogpy_ww21770_datasharing.core.courses courses
    on trackings.course = courses.id
where trackings.context_type='free'
group by 1, 2
order by nb_learners desc

Description