how to make a query that can combine count from one and some attributes from the other

I can imagine an update join possibly being along the lines of what you want here:

SELECT
    c.courseSectionNum,
    c.classroom,
    c.meetDays,
    c.beginTime,
    c.endTime,
    COALESCE(e.Total, 0) AS Total
FROM coursetbl c
LEFT JOIN
(
    SELECT courseSectionNum, COUNT(*) AS Total
    FROM enrolltbl
    WHERE courseID = 240
    GROUP BY courseSectionNum
) e
    ON e.courseSectionNum = c.courseSectionNum
WHERE
    c.courseID = 240;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top