SQL: stored procedure  for course statistics