0
$\begingroup$

I am trying to figure out how I can use aggregate functions to solve this problem. For example if I had the table

enrolled(student-id, course-id)
123 897
123 645
589 452
009 897

If I wanted to find the number of courses each student is enrolled in, how would I go about doing that? I was thinking of using the count function but I don't know how to separate each student-id

$\endgroup$

bumped to the homepage by Community 57 mins ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • $\begingroup$ You could use the group by operator. $\endgroup$ – Renzo Feb 13 at 15:33
0
$\begingroup$

Use the GROUP BY and COUNT operators.

$\endgroup$
  • $\begingroup$ just to clarify, is this in SQL or relational algebra? $\endgroup$ – temp948 Feb 13 at 17:43
  • $\begingroup$ @temp948, this is SQL. $\endgroup$ – D.W. Feb 13 at 19:38
  • $\begingroup$ i am talking about relational algebra here, not sql. $\endgroup$ – temp948 Feb 15 at 14:25
  • $\begingroup$ @temp948, perhaps you could edit the question to state that in the question? $\endgroup$ – D.W. Feb 15 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.