查询是否必须是此表单?

时间:2018-04-22 14:20:56

标签: sql

书名:数据库系统概念/作者:Silberschatz,Korth,Sudarshan

问题:找出已经上过ID 10101教师授课的(不同)学生的总数

回答:

select count(distinct ID)
from takes 
where (course_id, sec_id, semester, year) in
          (select course_id, sec_id, semester, year
           from teaches 
           where teaches.ID = 10101
          );

我的疑问:

select count (distinct ID)
from takes 
where course_id in (SELECT course_id from teaches where teaches.ID = 10101);

我必须是正确答案吗?

0 个答案:

没有答案