diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index 7ba7895..df1c330 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -536,31 +536,31 @@ WITH Funnel AS ( COUNT(*) >= 1 ), Questions AS ( - SELECT - q.id, - q.title AS question_title, - a.content AS answer_content, - COUNT(*)::FLOAT / NULLIF(q.total_answers, 0) AS percentage - FROM - answer a - JOIN ( - SELECT q.id, q.title, COUNT(*) AS total_answers - FROM question q - JOIN answer a ON q.id = a.question_id - WHERE a.quiz_id = $1 - AND a.created_at >= TO_TIMESTAMP($2) - AND a.created_at <= TO_TIMESTAMP($3) - GROUP BY q.id, q.title - ) q ON a.question_id = q.id - WHERE - a.quiz_id = $1 - AND a.created_at >= TO_TIMESTAMP($2) - AND a.created_at <= TO_TIMESTAMP($3) - GROUP BY - q.id, q.title, a.content - HAVING - COUNT(*) >= 1 - ) + SELECT + q.id, + q.title AS question_title, + a.content AS answer_content, + COUNT(*)::FLOAT / NULLIF(q.total_answers, 0) AS percentage + FROM + answer a + JOIN ( + SELECT q.id, q.title, COUNT(*) AS total_answers + FROM question q + JOIN answer a ON q.id = a.question_id + WHERE a.quiz_id = $1 + AND a.created_at >= TO_TIMESTAMP($2) + AND a.created_at <= TO_TIMESTAMP($3) + GROUP BY q.id, q.title + ) q ON a.question_id = q.id + WHERE + a.quiz_id = $1 + AND a.created_at >= TO_TIMESTAMP($2) + AND a.created_at <= TO_TIMESTAMP($3) + GROUP BY + q.id, q.title, a.content, q.total_answers + HAVING + COUNT(*) >= 1 + ) SELECT Funnel.count_start_false, Funnel.count_start_true, diff --git a/dal/sqlcgen/queries.sql.go b/dal/sqlcgen/queries.sql.go index 3fd290c..cddf33d 100644 --- a/dal/sqlcgen/queries.sql.go +++ b/dal/sqlcgen/queries.sql.go @@ -1630,31 +1630,31 @@ WITH Funnel AS ( COUNT(*) >= 1 ), Questions AS ( - SELECT - q.id, - q.title AS question_title, - a.content AS answer_content, - COUNT(*)::FLOAT / NULLIF(q.total_answers, 0) AS percentage - FROM - answer a - JOIN ( - SELECT q.id, q.title, COUNT(*) AS total_answers - FROM question q - JOIN answer a ON q.id = a.question_id - WHERE a.quiz_id = $1 - AND a.created_at >= TO_TIMESTAMP($2) - AND a.created_at <= TO_TIMESTAMP($3) - GROUP BY q.id, q.title - ) q ON a.question_id = q.id - WHERE - a.quiz_id = $1 - AND a.created_at >= TO_TIMESTAMP($2) - AND a.created_at <= TO_TIMESTAMP($3) - GROUP BY - q.id, q.title, a.content - HAVING - COUNT(*) >= 1 - ) + SELECT + q.id, + q.title AS question_title, + a.content AS answer_content, + COUNT(*)::FLOAT / NULLIF(q.total_answers, 0) AS percentage + FROM + answer a + JOIN ( + SELECT q.id, q.title, COUNT(*) AS total_answers + FROM question q + JOIN answer a ON q.id = a.question_id + WHERE a.quiz_id = $1 + AND a.created_at >= TO_TIMESTAMP($2) + AND a.created_at <= TO_TIMESTAMP($3) + GROUP BY q.id, q.title + ) q ON a.question_id = q.id + WHERE + a.quiz_id = $1 + AND a.created_at >= TO_TIMESTAMP($2) + AND a.created_at <= TO_TIMESTAMP($3) + GROUP BY + q.id, q.title, a.content, q.total_answers + HAVING + COUNT(*) >= 1 + ) SELECT Funnel.count_start_false, Funnel.count_start_true,