I tried solving the below question. I just want to make sure if I am correct.
student(student-name, street, city)
offering(department, number, section, time, population)
titles(department, number, title)
enrollment(student-name, department, number, section)
If I need to find The department, number, section, title, and population for every course section
The SQL query I tried is :
select a.department, a.number, a.section,b.title,population as "students"
from offering a ,titles b ,enrollment c,student d
where a.department=b.department
and a.number=b.number
and a.department=c.department
and a.number=c.number
and a.section=c.section
group by a.section
Please let me know if I am correct.
Thank you for your time and patience.
I don't believe that is correct, because the question doesn't refer to a Student. The question, as I understand it, is to get a list of all sections that are available, along with its title, which shouldn't need to join to Student. I believe just the Offering and Titles tables would be involved.
SELECT a.department, a.number, a.section, b.title, a.population
FROM offering a INNER JOIN titles b
ON a.department=b.department and a.number=b.number
ORDER BY a.department, a.number, a.section