fix question statistic query
This commit is contained in:
parent
5136009e94
commit
f756683012
@ -522,7 +522,7 @@ WITH Funnel AS (
|
|||||||
),
|
),
|
||||||
Results AS (
|
Results AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
COALESCE(q.title, '') AS question_title,
|
||||||
COUNT(*) AS total_answers,
|
COUNT(*) AS total_answers,
|
||||||
CAST(COUNT(*) * 100.0 / NULLIF(SUM(COUNT(*)) FILTER (WHERE a.result = TRUE) OVER (PARTITION BY a.quiz_id), 0) AS FLOAT8) AS percentage
|
CAST(COUNT(*) * 100.0 / NULLIF(SUM(COUNT(*)) FILTER (WHERE a.result = TRUE) OVER (PARTITION BY a.quiz_id), 0) AS FLOAT8) AS percentage
|
||||||
FROM
|
FROM
|
||||||
@ -587,18 +587,16 @@ SELECT
|
|||||||
Funnel.count_start_true,
|
Funnel.count_start_true,
|
||||||
Funnel.count_f_result_with_t_question,
|
Funnel.count_f_result_with_t_question,
|
||||||
Funnel.count_t_result,
|
Funnel.count_t_result,
|
||||||
Results.question_title AS results_title,
|
COALESCE(Results.question_title, '') AS results_title,
|
||||||
Results.percentage AS results_percentage,
|
COALESCE(Results.percentage, 0) AS results_percentage,
|
||||||
Questions.question_title AS questions_title,
|
COALESCE(Questions.question_title, '') AS questions_title,
|
||||||
COALESCE(Questions.question_page, 0) AS questions_page,
|
COALESCE(Questions.question_page, 0) AS questions_page,
|
||||||
Questions.answer_content AS answer_content,
|
COALESCE(Questions.answer_content, '') AS answer_content,
|
||||||
Questions.percentage AS questions_percentage
|
COALESCE(Questions.percentage, 0) AS questions_percentage
|
||||||
FROM
|
FROM
|
||||||
Funnel,
|
Funnel
|
||||||
Results,
|
LEFT JOIN Results ON true
|
||||||
Questions
|
LEFT JOIN Questions ON Questions.percentage >= 1;
|
||||||
WHERE
|
|
||||||
Questions.percentage >= 1;
|
|
||||||
|
|
||||||
-- name: QuizCopyQid :one
|
-- name: QuizCopyQid :one
|
||||||
INSERT INTO quiz (
|
INSERT INTO quiz (
|
||||||
|
Loading…
Reference in New Issue
Block a user