text: 
  SELECT
    requirements.id,
    courses.id as course,
    requirements.name,
    COUNT(DISTINCT activities.id) as activities,
    COUNT(DISTINCT reviews.id) as reviews,
    requirements.activities as tries,
    requirements.degree,
    requirements.sdate,
    requirements.edate,
    requirements.stamp,
    users.name as creator
  
  FROM
    requirements
      JOIN courses ON courses.id = requirements.course AND courses.deleted = 0
      LEFT JOIN activities ON activities.requirement = requirements.id AND activities.stashed = 0
      LEFT JOIN reviews ON reviews.activity = activities.id
      LEFT JOIN users ON users.id = requirements.creator
  
  WHERE
    requirements.deleted = 0
  
  GROUP BY
    requirements.id
    
  ORDER BY
    requirements.course,
    requirements.nu,
    requirements.name,
    requirements.creator,
    requirements.id;