解答
152
SQL文(クエリ)
WITH sales18 AS ( SELECT FORMAT_DATETIME("%Q", date_time) AS quarter , SUM(revenue) AS sum_rev18 FROM sample.sales WHERE FORMAT_DATETIME("%Y", date_time) = "2018" GROUP BY quarter ) , sales19 AS ( SELECT FORMAT_DATETIME("%Q", date_time) AS quarter , SUM(revenue) AS sum_rev19 FROM sample.sales WHERE FORMAT_DATETIME("%Y", date_time) = "2019" GROUP BY quarter ) SELECT quarter , sum_rev19 / sum_rev18 AS growth_rate FROM sales18 JOIN sales19 USING (quarter) ORDER BY 1