Week 122 - SQL & Query Techniques
You’ve just been appointed as the SQL expert at Dynamic Data Academy, a prestigious institution celebrated for its variaty of courses and programs. As part of your role, you’re tasked with analyzing enrollment data stored in the college’s Snowflake database. The table structure is as follows:
To create your dataset
CREATE TABLE student_enroll_info (student_id INT PRIMARY KEY,course VARCHAR(50),duration VARCHAR(50));
-- Step 2: Insert data into the table
INSERT INTO student_enroll_info (student_id, course, duration) VALUES
(1, 'CSE', 'Four Years'),
(2, 'EEE', 'Three Years'),
(3, 'CSE', 'Four Years'),
(4, 'MSC', 'Three Years'),
(5, 'BSC', 'Three Years'),
(6, 'Mech', 'Four Years');
How do you count the total number of students grouped by each course and duration separately?
Hint: Have you ever heard about GROUP BY GROUPING SETS? 😊