update sqlc gen

This commit is contained in:
Pavel 2024-03-17 21:03:58 +03:00
parent 7360a1350a
commit 0f05193fb5
2 changed files with 16 additions and 44 deletions

@ -535,36 +535,22 @@ WITH Funnel AS (
COUNT(*) >= 1
),
Questions AS (
SELECT
q.title AS question_title,
a.content AS answer_content,
CAST(COUNT(*) * 100.0 / NULLIF(SUM(COUNT(*)) OVER (PARTITION BY q.id), 0) AS INTEGER) AS percentage
FROM
answer a
JOIN (
SELECT
q.id,
q.title
q.title AS question_title,
a.content AS answer_content,
COUNT(a.id) * 100.0 / NULLIF(SUM(COUNT(a.id)) OVER (PARTITION BY q.id), 0) AS percentage
FROM
question q
JOIN
answer a ON q.id = a.question_id
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.title, a.content, q.id
HAVING
COUNT(*) >= 1
)
q.id, q.title, a.content
HAVING
COUNT(a.id) >= 1
)
SELECT
Funnel.count_start_false,
Funnel.count_start_true,

@ -1629,36 +1629,22 @@ WITH Funnel AS (
COUNT(*) >= 1
),
Questions AS (
SELECT
q.title AS question_title,
a.content AS answer_content,
CAST(COUNT(*) * 100.0 / NULLIF(SUM(COUNT(*)) OVER (PARTITION BY q.id), 0) AS INTEGER) AS percentage
FROM
answer a
JOIN (
SELECT
q.id,
q.title
q.title AS question_title,
a.content AS answer_content,
COUNT(a.id) * 100.0 / NULLIF(SUM(COUNT(a.id)) OVER (PARTITION BY q.id), 0) AS percentage
FROM
question q
JOIN
answer a ON q.id = a.question_id
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.title, a.content, q.id
HAVING
COUNT(*) >= 1
)
q.id, q.title, a.content
HAVING
COUNT(a.id) >= 1
)
SELECT
Funnel.count_start_false,
Funnel.count_start_true,