Classes More Than 5 Students Number of Unique Subjects Taught by Each Teacher SQL MySQL Leetcode

Описание к видео Classes More Than 5 Students Number of Unique Subjects Taught by Each Teacher SQL MySQL Leetcode

Challenge: Counting Unique Subjects per Teacher

Difficulty: Easy

Data:

A table named Teacher stores information about teachers and the subjects they teach:

teacher_id (int): Unique identifier for a teacher. (Primary Key)
subject_id (int): Identifier for the subject taught by the teacher.
dept_id (int): Identifier for the department offering the subject (may not be relevant for this task).
Objective:

Calculate the number of unique subjects each teacher teaches.

Output:

A table with two columns:

teacher_id (int): Unique identifier for a teacher (same as input table).
cnt (int): Number of unique subjects taught by this teacher.
Explanation:

We need to count the distinct subject_id values for each unique teacher_id in the Teacher table.

Challenge: Finding Large Classes

Difficulty: Easy

Data:

A table named Courses stores information about student enrollment in classes:

student (varchar): Name of the student enrolled in the class.
class (varchar): Name of the class the student is enrolled in. (Primary Key along with student)
Objective:

Find all classes with at least five students enrolled.

Output:

A table with a single column:

class (varchar): Name of the class that has at least five students enrolled (same as input table).
Explanation:

We need to identify classes with a count of distinct student names (student) exceeding five within the Courses table.

Комментарии

Информация по комментариям в разработке