Get startedGet started for free

Digging into charging costs

Let's take it a level deeper! Previously, you provided a ranking for each charging station based on the cost of each charge. Now, let's find a bit more information about the charging cost for sessions at each charging station.

This exercise is part of the course

Window Functions in Snowflake

View Course

Exercise instructions

  • Determine the charging cost of the first charge at each station, based on the charging_start_time.
  • Find the average charging_cost for each charging station.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT
    user_id,
    charging_station_id,
    charging_cost,
    
    -- Based on the charging_start_time, find the first 
    -- charging cost for each location
	___(___) OVER(
    	PARTITION BY charging_station_id
      	ORDER BY ___
    ) AS first_charging_cost,

	-- Find the average charging cost for charging station id
    ___(___) ___(
        ___ ___ ___
    ) AS average_charging_cost
    
FROM ELECTRIC_VEHICLES.charging
ORDER BY charging_station_id;
Edit and Run Code