1. Learn
  2. /
  3. Courses
  4. /
  5. Window Functions in Snowflake

Connected

Exercise

Lightning charger load

The machine learning team is interested in predicting the energy consumed in a charger's next session, with the goal of routing power to the chargers who might be taxed in the future. To train a model, they'd like you to prepare a dataset that includes information about the user, vehicle model, charging station, and energy consumed that "looks" forward to the next charge. Time to show them what you've got!

Instructions

100 XP
  • Retrieve the time_of_day, charging_rate, and energy_consumed for each record from the ELECTRIC_VEHICLES.charging table.
  • Use a window function to "look ahead" and retrieve the energy consumed in the next charging session; return 0 if not found.
  • Segment the records by charging_station_id and use the charging_start_time to create a sequence of records, in ascending order.
Powered by Snowflake