学生模式的sql查询

学生模式的sql查询,sql,relational,Sql,Relational,我试着解决下面的问题。我只是想确定我是否正确 学生(学生姓名、街道、城市) 提供(部门、编号、部门、时间、人口) 职务(部门、编号、职务) 注册(学生姓名、系、号、科) 如果我需要查找每个课程部分的部门、编号、部分、标题和人数 我尝试的SQL查询是: select a.department, a.number, a.section,b.title,population as "students" from offering a ,titles b ,enrollment c,student d

我试着解决下面的问题。我只是想确定我是否正确

学生(学生姓名、街道、城市)
提供(部门、编号、部门、时间、人口)
职务(部门、编号、职务)
注册(学生姓名、系、号、科)

如果我需要查找每个课程部分的部门、编号、部分、标题和人数

我尝试的SQL查询是:

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
请让我知道我是否正确


谢谢你的时间和耐心。

我认为这是不对的,因为这个问题不是针对学生的。据我所知,问题是获得所有可用部分的列表,以及它的标题,这些部分不需要加入到学生中。我相信只需要提供和标题表就可以了

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

我试着重做了一遍,认为我需要得到每个部分的部门、编号、部门、标题和人口<代码>选择a.department、a.number、a.section、b.title、a.population从产品a、titles b中选择a.department=b.department和a.number=b.number按a.section分组是的,我认为这是正确的。你也可以把它当作一个连接,我会把它放在答案里。由于没有聚合函数,您可以使用order by而不是group by。此外,仅供参考,如果您觉得评论和答案有用,您可以/应该对其进行投票。另外,记住接受最能回答你问题的答案。哦,好的。我在考虑使用group by,因为每个部分都应该显示部门、编号、标题和人口。当然,我一定会对评论进行投票。非常感谢您,您发布的表格中有些地方不正确。您要查找的内容都在
offering
表中。不,它使用titles中的title列和department表中的其余列。