List Unique Student MajorsEasy

List Unique Student Majors

EasySQLPractice library · +10 XPdistinct valuessqluniversity

UptoSkills Arena is collecting data on academic programs. You are given a table containing information about students and their declared majors.

Your task is to find all the unique academic majors that students are currently pursuing. Do not include any major that is NULL.

Return the majors in alphabetical order. If the result set is empty, return an empty set.

Tables:

  • Students (student_id INT, major VARCHAR(50))

Return:

  • major (VARCHAR(50))

Order the results by major.

Tables

CREATE TABLE Students (
    student_id INTEGER PRIMARY KEY,
    major VARCHAR(50)
);

Example data

INSERT INTO Students (student_id, major)
VALUES
(1, 'Computer Science'),
(2, 'Physics'),
(3, 'Computer Science'),
(4, 'Mathematics'),
(5, 'Physics'),
(6, 'Biology'),
(7, 'Computer Science'),
(8, 'Chemistry');

Your query is also checked on hidden datasets with different data.

Hints