LoslegenKostenlos loslegen

Are charging durations getting longer?

The Data Science team currently has a model that predicts the number of open chargers based on average vehicle charging duration. This allows for them to send notifications to previous users when it might be a good time to charge. However, the team believes that average charging duration may have changed since the last time they trained their model. Can you validate this for them?

Diese Übung ist Teil des Kurses

Window Functions in Snowflake

Kurs anzeigen

Anleitung zur Übung

  • Use a window function to find the running average of vehicle charging_duration.
  • Partition the results by charging_station_location.
  • Sequence the window by charging_start_time in ascending order.
  • Create the window of records to always be between the first row and the CURRENT ROW.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

SELECT
	user_id,
    charging_station_location,
	TO_DATE(charging_start_time),
    charging_duration,

    -- Find the running average of charging duration
    ___ OVER(
      	-- Partition the results by charging_station_location
      	___

        -- Sequence the results by charging start time in ascending order
        ORDER BY ___

        -- Create the window of records to always be between the 
      	-- first row and the current row
        ___

    ) AS running_average
FROM ELECTRIC_VEHICLES.charging;
Code bearbeiten und ausführen