/*2.9. Hacer un query que liste los alumnos que están morosos en todos los cursos en los que están inscriptos.*/

SELECT DISTINCT fullname
FROM
(
  SELECT *
  FROM enrollments
  WHERE student_iid IN
  (
    SELECT *
    FROM
    (
      SELECT student_iid st_id
      FROM enrollments
      GROUP BY student_iid, paid
      ORDER BY st_id
    )
    AS first
    GROUP BY first.st_id
    HAVING count(first.st_id) = 1
  )
  AND paid = 'false'
)
AS elegidos
  LEFT JOIN
    students st
ON elegidos.student_iid = st.student_iid  ;
