List Unique Student Majors
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_idINT,majorVARCHAR(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
-- Write your query here
SELECT major
FROM Students
Your query runs on the example tables shown with the problem, then on hidden datasets when you submit.
Write standard SQL. MySQL habits work too: IFNULL, IF, YEAR(), DATE_FORMAT, GROUP_CONCAT, `backticks` and LIMIT 5, 10. It runs on PostgreSQL, so integer division keeps whole numbers (5 / 2 = 2): write 5.0 / 2 for 2.5.