ComenzarEmpieza gratis

Maintaining charger efficiency

As vehicle chargers age, their efficiency often wanes. The operations team is interested in performing proactive maintenance and identifying when a charger may need to be replaced. To do this, they'd like to have a report that tracks the change in charging rate in the last three charges. Let's see if you can give them a hand!

Este ejercicio forma parte del curso

Window Functions in Snowflake

Ver curso

Instrucciones del ejercicio

  • Use a window function to find the difference between the charging_rate for the current session and the charging_rate from 3 sessions ago.
  • Partition the result set data by the charging_station_location to make sure that results are isolated to each charging station.
  • Determine the sequence of sessions using the charging_start_time, in ascending order.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

SELECT
    user_id,
    charging_station_location,
    charging_start_time,
    charging_rate,
	
    -- Difference between current charging rate versus three sessions ago
    ___ - ___(___, ___, 0) OVER(
      	
      	-- Make sure results are partitioned by charging_station_location
        ___
      
      	-- Sessions should be ordered by when charging began
        ___
      
    ) AS change_in_charging_rate

FROM ELECTRIC_VEHICLES.charging;
Editar y ejecutar código