diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index d7ca343..e93772b 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -282,7 +282,18 @@ WHERE privilege_name = $2 AND (amount < $3 OR created_at <= NOW() - INTERVAL '1 month'); -- name: GetAllAnswersByQuizID :many -SELECT DISTINCT ON(question_id) content, created_at, question_id, id FROM answer WHERE session = $1 AND start = false ORDER BY question_id ASC, created_at DESC; +SELECT DISTINCT ON (a.question_id) + a.content, a.created_at, a.question_id, a.id, q.questiontype, quiz.qid +FROM + answer a + JOIN + question q ON a.question_id = q.id + JOIN + quiz ON q.quiz_id = quiz.id +WHERE + a.session = $1 AND a.start = false AND a.deleted = false +ORDER BY + a.question_id ASC, a.created_at DESC; -- name: InsertAnswers :exec INSERT INTO answer( content,