Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL for Course Enrollment Metrics
00:00
5 left

SQL for Course Enrollment Metrics

MediumSQL · PostgreSQL

Problem

Patreon’s internal creator education catalog needs a report showing which active professors are associated with each department and which published courses they teach. Write a PostgreSQL query using the relationships among professors, departments, and courses.

Requirements

  1. Return every active professor, including professors with no published courses or no assigned department.
  2. Display the professor name, department name, number of published courses, and a comma-separated alphabetical list of published course titles.
  3. Show 0 and None when an active professor has no published courses.
  4. Order by published course count descending, then professor name ascending.

Schema

professors
ColumnTypeDescription
professor_idPKINTUnique professor identifier
professor_nameVARCHAR(100)Professor’s name
department_idINTReferences departments.department_id
is_activeBOOLEANWhether the professor is active
departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Department name
courses
ColumnTypeDescription
course_idPKINTUnique course identifier
course_titleVARCHAR(150)Course title
professor_idINTReferences professors.professor_id
statusVARCHAR(20)Course publication status
Tablesprofessorsdepartmentscourses
Interviewer

Your question is SQL for Course Enrollment Metrics. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.