Identificar cargadores ineficientes
Con el tiempo, los cargadores se vuelven menos eficientes. Cuando esto ocurre, estos cargadores necesitan mantenimiento o sustitución. Se determina si un cargador es eficiente o ineficiente en función de su tasa de carga. Para ayudarte a identificar cargadores que podrían necesitar una puesta a punto, tendrás que crear una consulta que use marcos de ventana para encontrar la tasa media de carga y el número restante de sesiones de un cargador. ¡Suerte!
Este ejercicio forma parte del curso
Funciones de ventana en Snowflake
Instrucciones del ejercicio
- Calcula la media de
charging_rateporcharging_station_locationusando un marco de ventana entre la primera fila y la fila actual. - Cuenta el número de registros por
charging_station_location. - Crea un marco de ventana entre la fila actual y la última fila, ordenado por
charging_start_time.
ejercicio interactivo práctico
Prueba este ejercicio completando este código de ejemplo.
SELECT
user_id,
TO_DATE(charging_start_time),
charging_station_location,
charging_rate,
-- Find the average charging rate, by charging station location
-- using a window frame between the first row and current row
___(___) OVER(
PARTITION BY ___
ORDER BY charging_start_time
ROWS BETWEEN ___ ___ AND ___ ___
) AS running_average_charging_rate,
-- Count the number of records by charging station location
___(*) OVER(
PARTITION BY charging_station_location
-- Create a window frame between the current row and the
-- last row, ordered by charging start time
ORDER BY ___
ROWS BETWEEN ___ ___ AND ___ ___
) AS remaining_charges
FROM ELECTRIC_VEHICLES.charging
ORDER BY charging_station_location, charging_start_time;