SQL到关系代数

时间:2015-12-11 02:15:11

标签: sql oracle algebra relational-algebra

如何在关系代数中将其变为白色?我总是对那些GROUP BY和HAVING COUNT感到困惑......无法真正表达出来。

SELECT DISTINCT Name
FROM studies, course
WHERE (SELECT COUNT(course_id) FROM studies
GROUP BY course_id HAVING COUNT (course_id) > 1) >= 2
AND (SELECT course_id FROM studies
GROUP BY course_id HAVING COUNT (course_id) > 1) = course.course_id;

1 个答案:

答案 0 :(得分:0)

如果我正确理解您的评论,那么您只需将join表格放在一起,并使用group by having {/ 1>}

select c.course_id, c.name
from course c
   join studies s on c.course_id = s.course_id
group by c.course_id, c.name
having count(s.course_id) > 1