File size: 467 Bytes
27ec678 | 1 2 3 4 | -- Consent records subscribed to marketing
-- Consent records captured in the month with status subscribed, over all captured.
SELECT strftime(captured_at, '%Y-%m') AS month, sum(CASE WHEN status = 'subscribed' THEN 1 ELSE 0 END) AS num, sum(1) AS den, sum(CASE WHEN status = 'subscribed' THEN 1 ELSE 0 END) / NULLIF(sum(1), 0) AS value FROM marketing.consent WHERE captured_at >= TIMESTAMP '2023-10-01' AND captured_at < TIMESTAMP '2026-10-01' GROUP BY 1 ORDER BY 1
|