This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*NPS ROLLING 30-DAYS AVG AND DAILY SCORE CHART*/ | |
SELECT a.date, | |
a.net_promoters / a.responses * 100 AS score, | |
(SUM(b.net_promoters) | |
/ | |
SUM(b.responses)) * 100 AS score_30d | |
FROM ( | |
SELECT date(s.created_at) AS date, | |
SUM(CASE WHEN s.score >= 9 THEN 1.0 | |
WHEN s.score <= 6 THEN -1.0 |