File size: 431 Bytes
27ec678
 
 
1
2
3
4
-- CSAT (share of ratings 4 or 5)
-- Survey responses scoring 4 or 5, over all responses received in the month.
SELECT strftime(created_at, '%Y-%m') AS month, sum(CASE WHEN score >= 4 THEN 1 ELSE 0 END) AS num, sum(1) AS den, sum(CASE WHEN score >= 4 THEN 1 ELSE 0 END) / NULLIF(sum(1), 0) AS value FROM support.csat_response WHERE created_at >= TIMESTAMP '2023-10-01' AND created_at < TIMESTAMP '2026-10-01' GROUP BY 1 ORDER BY 1