Error in solutions to exam from VT2011

57 views
Skip to first unread message

Niklas Broberg

unread,
Mar 7, 2014, 1:38:01 AM3/7/14
to tda357...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages