easy

Courses With No Enrolled Students

Courses With No Enrolled Students

You are a data analyst at LearnSphere, an online education platform offering courses across a wide range of subjects. As the new semester begins, the operations team wants to identify courses that have not yet attracted any student enrolments — so they can prioritise outreach and promotional efforts for those courses.

You have access to two tables:

Table: courses

Column

Type

Description

course_id

INT

Unique course identifier

course_name

VARCHAR

Name of the course

instructor

VARCHAR

Name of the course instructor

category

VARCHAR

Subject category (e.g., Design, Data Science)

Table: enrolments

Column

Type

Description

enrolment_id

INT

Unique enrolment identifier

course_id

INT

References the course the student enrolled in

student_id

INT

Unique identifier of the student

enrolled_date

DATE

Date the student enrolled

Your Task:

Write a query that returns all courses that have zero student enrolments. Sort the results alphabetically by course_name.

Expected Output Columns: course_id, course_name, instructor, category

1
2
3
4
5
Preparing...
Courses With No Enrolled Students

Courses With No Enrolled Students You are a data analyst at LearnSphere , an online education platform offering courses across a wide range of subjects. As the new semester begins, the operations team wants to identify courses that have not yet attracted any student enrolments — so they can prioritise outreach and promotional efforts for those courses. You have access to two tables: Table: courses Column Type Description course_id INT Unique course identifier course_name VARCHAR Name of the course instructor VARCHAR Name of the course instructor category VARCHAR Subject category (e.g., Design, Data Science) Table: enrolments Column Type Description enrolment_id INT Unique enrolment identifier course_id INT References the course the student enrolled in student_id INT Unique identifier of the student enrolled_date DATE Date the student enrolled Your Task: Write a query that returns all courses that have zero student enrolments . Sort the results alphabetically by course_name . Expected Output Columns: course_id , course_name , instructor , category

Table Setup (SQL Schema)

-- DDL: Create tables
CREATE TABLE courses (
    course_id   INT PRIMARY KEY,
    course_name VARCHAR(200),
    instructor  VARCHAR(150),
    category    VARCHAR(100)
);

CREATE TABLE enrolments (
    enrolment_id  INT PRIMARY KEY,
    course_id     INT REFERENCES courses(course_id),
    student_id    INT,
    enrolled_date DATE
);

-- DML: Insert sample data
INSERT INTO courses (course_id, course_name, instructor, category) VALUES
(1,  'Intro to Python',             'Dr. Alan Shore',     'Data Science'),
(2,  'Machine Learning Basics',     'Dr. Priya Nair',     'Data Science'),
(3,  'UI/UX Design Fundamentals',   'Sarah Okafor',       'Design'),
(4,  'Advanced Figma Techniques',   'Sarah Okafor',       'Design'),
(5,  'SQL for Beginners',           'James Whitfield',    'Data Science'),
(6,  'Web Development Bootcamp',    'Carlos Rivera',      'Engineering'),
(7,  'Docker & Kubernetes 101',     'Ming Zhang',         'Engineering'),
(8,  'Personal Finance Essentials', 'Laura Benson',       'Finance'),
(9,  'Blockchain Fundamentals',     'Dr. Kofi Mensah',    'Engineering'),
(10, 'Digital Marketing Strategy',  'Amelia Thornton',    'Marketing');

INSERT INTO enrolments (enrolment_id, course_id, student_id, enrolled_date) VALUES
(1,  1, 101, '2024-02-01'),
(2,  1, 102, '2024-02-03'),
(3,  1, 103, '2024-02-05'),
(4,  2, 101, '2024-02-06'),
(5,  2, 104, '2024-02-07'),
(6,  3, 105, '2024-02-08'),
(7,  3, 106, '2024-02-09'),
(8,  5, 102, '2024-02-10'),
(9,  5, 107, '2024-02-11'),
(10, 5, 108, '2024-02-12'),
(11, 6, 103, '2024-02-13'),
(12, 6, 109, '2024-02-14'),
(13, 8, 110, '2024-02-15'),
(14, 10, 104, '2024-02-16'),
(15, 10, 105, '2024-02-17');
Home Videos Quiz Blog