WITH inflation_data AS
(
SELECT
"year",
"inflation_rate",
EXP(SUM(LN(1 + "inflation_rate")) OVER (ORDER BY "year")) as "comp_inflation"
FROM @kaggle.prasertk_300_years_of_inflation_rate_in_us.inflation_data_1701_2022
WHERE "year" >= 1985
ORDER BY "year"
)
SELECT
fire_data."year",
fire_data."fires",
fire_data."acres",
CAST(REPLACE(REPLACE(fire_data."total", '$', ''), ',', '') AS BIGINT) AS "cost (nominal)",
CAST(REPLACE(REPLACE(fire_data."total", '$', ''), ',', '') AS BIGINT) / inflation_data."comp_inflation" * (SELECT "comp_inflation" FROM inflation_data WHERE "year" = 2020 ) AS "cost (inflation-adjusted)",
CAST(REPLACE(REPLACE(fire_data."doiagencies", '$', ''), ',', '') AS BIGINT) AS "department of interior costs",
fire_data."acres",
CAST(REPLACE(REPLACE(fire_data."forestservice", '$', ''), ',', '') AS BIGINT) AS "forestservice cost"
FROM
@kaggle.kkhandekar_total_wildfires_acres_affected_1983_2020.federal_firefighting_costs_suppression_only AS fire_data
INNER JOIN inflation_data
ON fire_data."year" = inflation_data."year"