update sqlc gen

This commit is contained in:
Pavel 2024-03-17 20:45:06 +03:00
parent 716f49bc49
commit 7360a1350a
2 changed files with 6 additions and 8 deletions

@ -538,14 +538,13 @@ WITH Funnel AS (
SELECT
q.title AS question_title,
a.content AS answer_content,
CAST(COUNT(*) * 100.0 / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage
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,
COUNT(*) AS total_answers
q.title
FROM
question q
JOIN
@ -562,7 +561,7 @@ WITH Funnel AS (
AND a.created_at >= TO_TIMESTAMP($2)
AND a.created_at <= TO_TIMESTAMP($3)
GROUP BY
q.title, a.content, q.total_answers
q.title, a.content, q.id
HAVING
COUNT(*) >= 1
)

@ -1632,14 +1632,13 @@ WITH Funnel AS (
SELECT
q.title AS question_title,
a.content AS answer_content,
CAST(COUNT(*) * 100.0 / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage
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,
COUNT(*) AS total_answers
q.title
FROM
question q
JOIN
@ -1656,7 +1655,7 @@ WITH Funnel AS (
AND a.created_at >= TO_TIMESTAMP($2)
AND a.created_at <= TO_TIMESTAMP($3)
GROUP BY
q.title, a.content, q.total_answers
q.title, a.content, q.id
HAVING
COUNT(*) >= 1
)