Impact of temperature on charging rate
The data you've been interrogating with window functions isn't just insightful for your team; it's quite useful for vehicle manufacturers themselves. A number of these manufacturers have come to you interested in the impact of temperature on charging rate. They'd like a moving average of temperature, as well as a moving average for charging rate broken out by vehicle model.
Este ejercicio forma parte del curso
Window Functions in Snowflake
Instrucciones del ejercicio
- Find the moving average of
temperature
using the two preceding records and the current row, ordered bytemperature
. - Generate another moving average, this time for
charging_rate
using the four preceding records and the current row, again ordered bytemperature
and partitioned byvehicle_model
. - Only include records where
charging_rate
is notNULL
.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
SELECT
vehicle_model,
charger_type,
temperature,
charging_rate,
-- Create a moving average of temperature using the two preceding and following records
___(___) OVER(
PARTITION BY vehicle_model
ORDER BY ___
ROWS BETWEEN ___ ___ AND ___ ___
) AS moving_average_temperature,
-- Find the moving average charging rate for the preceding four charging sessions
___(___) OVER(
PARTITION BY ___
ORDER BY ___
___
) AS moving_average_charging_rate
FROM ELECTRIC_VEHICLES.charging
-- Only include non-NULL charging rates
WHERE ___
ORDER BY vehicle_model, charger_type, temperature;