query the id number of the student who enrolled c2 or c4 course.

by Mr. Claud Adams 8 min read

How to get the number of students enrolled in a course?

a) Query the id number of the students who at least enrolled C2 and C4 courses. b) Query the id number, name, and age of the students who did not enroll C2 course. c) Query the names of the students who enrolled all of the courses.

How to group all students of a course in a course?

Dec 19, 2017 · SELECT c.class_name "Class Name", count(distinct j.student_id) "Number of Students" FROM class c LEFT JOIN junction j ON j.class_id = c.class_id GROUP BY 1 Share Follow

Which table has the student_ID and Student_Name column?

Query the following in T-SQL format: Query the id number of the students who at least enrolled C2 and C4 courses. Query the id number, name, and age of the students who did not enroll C2 course. Query the names of the students who enrolled all of the courses.

How can I get a list of all students enrolled?

Jan 25, 2015 · Here, firstly the inner query is solved. It returns all the Enrollment Numbers (SELECT S2.EnrollNo) of students where the students’ enrollment number matches with the enrollment number of the courses (WHERE S2.EnrollNo = E2.EnrollNo) which have the course IDs whose Course Name is “OS” (E2.CourseID = C2.CourseID and C2.Name = “OS”).

The Challenge

Given the database tables below, use your SQL skills to answer as many of the questions that follow.

Solutions

There are multiple ways to write the SQL queries that answer this challenge’s questions, so they may not exactly match your own. Here are my answers to the questions. Check out the solutions Gist, if you prefer to view them there.