select course_id, sec_id, count(ID)
from section natural join takes
where semester = 'Fall' and year = 2009
group by course_id, sec_id
求大佬帮忙改一下,让他能在Sql server2008上运行
select course_id, sec_id, count(ID)
from section natural join takes
where semester = 'Fall' and year = 2009
group by course_id, sec_id
求大佬帮忙改一下,让他能在Sql server2008上运行
mssqlserver不支持natural join,改成inner join或者join。
select section.course_id, section.sec_id, count(section.ID)--防止重名最好加上表名称,要不2个表中字段一样会出错
from section
inner join takes on section.sec_id=takes.sec_id--自己注意改下这里,2个表中通过哪个字段关联的,我这里只是猜测的
where semester = 'Fall' and year = 2009
group by course_id, sec_id
对你有帮助能点击个采纳吗,谢谢~