I am trying to evaluate if someone has read and seen all the questions of a book.I am using PHP to average everything out after I get the data. I know MySQL can avg, but I can't seem to wrap my head around how I can average the box number of the questions (similar to spaced repetition learning) if they haven't seen every question.How can this function be better? I feel there might be a more elegant way of doing it.SELECT COUNT(s.id),       (SELECT COUNT(u.id)           FROM user_sections u          WHERE u.chpt_id = ? && u.user_id = ?       ),        (SELECT COUNT(q.id)           FROM question q          WHERE q.chapter_id = ? && (q.module = 1 || q.module = ?)       ),       (SELECT COUNT(v.id)           FROM user_questions v          WHERE v.chpt_id = ? && u.user_id = ?       ),        (SELECT AVG(v.box)           FROM user_questions v          WHERE v.chapter_id = ? && u.user_id=?       ),       (SELECT AVG(m.$mkts_col)           FROM mkts m          WHERE m.chapter_id = ? && (m.module = 1 || m.module = ?)       )  FROM sections s  WHERE s.chapter_id = ? && (s.module = 1 || s.module = ?)
Determining if someone has read and seen all the questions of a book
performance;sql;mysql;mysqli