快充樁負載
機器學習團隊想預測充電器在「下一次充電工作階段」的用電量,目標是將電力優先配置給未來可能負載較高的充電器。為了訓練模型,他們希望你準備一個資料集,包含使用者、車款、充電站,以及向前「看」到下一次充電的用電量。是時候展現你的身手了!
本練習屬於課程
Snowflake 的 Window Functions
練習說明
- 從
ELECTRIC_VEHICLES.charging資料表擷取每筆紀錄的time_of_day、charging_rate與energy_consumed。 - 使用視窗函式「往前看」並擷取下一次充電工作階段的用電量;若沒有找到則回傳
0。 - 以
charging_station_id分段紀錄,並使用charging_start_time建立遞增排序的紀錄序列。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
SELECT
user_id,
charging_station_id,
charging_start_time,
-- Retrieve the time_of_day, charging_rate and energy_consumed fields
___,
___,
___,
-- "Look ahead" to the energy consumed in the next session
___ OVER(
-- Segment the records by charging station and sequence
-- records by the start time of the charge
___
___
) AS next_session_energy_consumed
FROM ELECTRIC_VEHICLES.charging;