Identifier les bornes inefficaces
Avec le temps, les bornes deviennent moins efficaces. Dans ce cas, elles doivent être maintenues ou remplacées. L’efficacité d’une borne est déterminée selon son débit de charge. Pour aider à repérer les bornes qui pourraient nécessiter une remise à niveau, vous allez écrire une requête qui utilise des fenêtres pour trouver le débit de charge moyen et le nombre restant de sessions pour une borne. Bonne chance !
Cet exercice fait partie du cours
<cours>Fonctions de fenêtre dans Snowflake</cours>Instructions de l’exercice
- Calculez la moyenne de
charging_rate, parcharging_station_location, en utilisant une fenêtre entre la première ligne et la ligne courante. - Comptez le nombre d’enregistrements par
charging_station_location. - Créez une fenêtre entre la ligne courante et la dernière ligne, ordonnée par
charging_start_time.
Exercice interactif pratique
Essayez cet exercice en complétant ce code d’exemple.
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;