Using the Art Course tables of course, enrollment and customer, (download and ru
ID: 3875768 • Letter: U
Question
Using the Art Course tables of course, enrollment and customer, (download and run the Art Course Tables sql script) I want to find how many students are enrolled in each course. If no students are enrolled, I want the course to appear in the result with a count of 0 I do the query select * from course c, enrollment e, customer s where s.customernumber e.customernumber and e.coursenumber c.coursenumber group by c courseNumber and get back the result CourseNumber Course Fee Adv Pastels 2015-10-0100:00:00 500.00 1 Beg Ols Int Pastels 2015-03-15 00:00:00 350.00 Beg Ois Adv Pastels 2015-11-15 00:00:00 00.00 6 250.00 350.00 350.00 0.00 250.00 Green Johnson Myers Anie Robin Ariel Lynda Leah 206-567-1234 425 678-8765 206-567-1234 360-789-5678 425-678-7654 2015-09-15 00:00:00 350.00 2 2015-10-15 00:00:00 30.00 7 2. 3. Explain the result that is returned by MySQL and why it is incorrect. What would be the correct select statement to get the information?Explanation / Answer
Answer)
2) Selecting values from course c, enrollment 3 and customer s. We join the tables using s.customernumber = e.customernumber and e.coursenumber = c.coursenumber. We have no count of the students who are enrolled in the course. So group by and count have to be used together for the above purpose.
3) As we don't have the data shared above, we'll modify the query here given above -
select c.coursenumber, count(e.customernumber)
from course c, enrollment e, customer s
where s.customernumber = e.customernumber and
e.coursenumber = c.coursenumber
group by c.coursenumber;
Here we display the coursenumber and the count of the number of students enrolled in each course.
//Please like my answer if it helped you. Thanks.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.