update sqlc gen
This commit is contained in:
parent
d95d690cbe
commit
5f596d7358
@ -500,30 +500,22 @@ WITH Funnel AS (
|
|||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
),
|
),
|
||||||
Results AS (
|
Results AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
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 percentage
|
||||||
COUNT(CASE WHEN a.result = TRUE THEN 1 ELSE NULL END) * 100.0 / NULLIF(SUM(COUNT(CASE WHEN a.result = TRUE THEN 1 ELSE NULL END)) OVER (PARTITION BY q.id), 0) AS FLOAT8
|
FROM
|
||||||
) AS percentage
|
question q
|
||||||
FROM
|
JOIN answer a ON q.id = a.question_id
|
||||||
answer a
|
WHERE
|
||||||
JOIN question q ON a.question_id = q.id
|
a.quiz_id = $1
|
||||||
WHERE
|
AND a.created_at >= TO_TIMESTAMP($2)
|
||||||
a.quiz_id = $1
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
AND a.created_at >= TO_TIMESTAMP($2)
|
GROUP BY
|
||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
q.title, a.quiz_id
|
||||||
AND q.id IN (
|
HAVING
|
||||||
SELECT DISTINCT a.question_id
|
COUNT(*) >= 1
|
||||||
FROM answer a
|
),
|
||||||
WHERE a.quiz_id = $1
|
|
||||||
AND a.result = TRUE
|
|
||||||
)
|
|
||||||
GROUP BY
|
|
||||||
q.id, q.title
|
|
||||||
HAVING
|
|
||||||
COUNT(*) >= 1
|
|
||||||
),
|
|
||||||
Questions AS (
|
Questions AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
q.title AS question_title,
|
||||||
|
@ -1594,30 +1594,22 @@ WITH Funnel AS (
|
|||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
),
|
),
|
||||||
Results AS (
|
Results AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
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 percentage
|
||||||
COUNT(CASE WHEN a.result = TRUE THEN 1 ELSE NULL END) * 100.0 / NULLIF(SUM(COUNT(CASE WHEN a.result = TRUE THEN 1 ELSE NULL END)) OVER (PARTITION BY q.id), 0) AS FLOAT8
|
FROM
|
||||||
) AS percentage
|
question q
|
||||||
FROM
|
JOIN answer a ON q.id = a.question_id
|
||||||
answer a
|
WHERE
|
||||||
JOIN question q ON a.question_id = q.id
|
a.quiz_id = $1
|
||||||
WHERE
|
AND a.created_at >= TO_TIMESTAMP($2)
|
||||||
a.quiz_id = $1
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
AND a.created_at >= TO_TIMESTAMP($2)
|
GROUP BY
|
||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
q.title, a.quiz_id
|
||||||
AND q.id IN (
|
HAVING
|
||||||
SELECT DISTINCT a.question_id
|
COUNT(*) >= 1
|
||||||
FROM answer a
|
),
|
||||||
WHERE a.quiz_id = $1
|
|
||||||
AND a.result = TRUE
|
|
||||||
)
|
|
||||||
GROUP BY
|
|
||||||
q.id, q.title
|
|
||||||
HAVING
|
|
||||||
COUNT(*) >= 1
|
|
||||||
),
|
|
||||||
Questions AS (
|
Questions AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
q.title AS question_title,
|
||||||
@ -1667,7 +1659,7 @@ type QuestionsStatisticsRow struct {
|
|||||||
CountFResultWithTQuestion int64 `db:"count_f_result_with_t_question" json:"count_f_result_with_t_question"`
|
CountFResultWithTQuestion int64 `db:"count_f_result_with_t_question" json:"count_f_result_with_t_question"`
|
||||||
CountTResult int64 `db:"count_t_result" json:"count_t_result"`
|
CountTResult int64 `db:"count_t_result" json:"count_t_result"`
|
||||||
ResultsTitle string `db:"results_title" json:"results_title"`
|
ResultsTitle string `db:"results_title" json:"results_title"`
|
||||||
ResultsPercentage float64 `db:"results_percentage" json:"results_percentage"`
|
ResultsPercentage int32 `db:"results_percentage" json:"results_percentage"`
|
||||||
QuestionsTitle string `db:"questions_title" json:"questions_title"`
|
QuestionsTitle string `db:"questions_title" json:"questions_title"`
|
||||||
AnswerContent sql.NullString `db:"answer_content" json:"answer_content"`
|
AnswerContent sql.NullString `db:"answer_content" json:"answer_content"`
|
||||||
QuestionsPercentage float64 `db:"questions_percentage" json:"questions_percentage"`
|
QuestionsPercentage float64 `db:"questions_percentage" json:"questions_percentage"`
|
||||||
|
Loading…
Reference in New Issue
Block a user