Question 5A(ii) reads:
Translate the following relational algebra expression to SQL:
[gamma]post,COUNT−DISTINCT(name)→posters(Comments [outerjoin] OtherComments)
In the draft solutions, the suggested answer is:
SELECT post, COUNT(DISTINCT name) as posters
FROM Comments NATURAL OUTER JOIN Posters;
This is incorrect, the above SQL query is not even valid since it mixes ordinary projection with aggregation. The correct answer should be:
SELECT post, COUNT(DISTINCT name) as posters
FROM Comments NATURAL OUTER JOIN Posters
GROUP BY post;
i.e. with an added GROUP BY clause at the end.
Thanks for pointing this out to me.
/Niklas