BaşlayınÜcretsiz Başlayın

Setting a minimum charging cost

The company that owns these chargers wants to set a minimum charging cost for each city they operate. To do this, they'd like to make the cost of the tenth-cheapest charging cost for each city the minimum that each user must spend when charging their vehicle in any given session. As the resident Snowflake expert, it's your job to find this value for each city to eventually compare each record to it.

Bu egzersiz

Window Functions in Snowflake

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use a window function to find the tenth-smallest value of charging_cost.
  • Partition data by charging_station_location to ensure that a minimum value is found for each city.
  • Alias the results as the minimum_cost.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

SELECT
	charging_station_location,
	user_id,
	charging_cost,
    
    -- Find the tenth-smallest charging cost
    ___(___, ___) OVER(
      	-- Segment the data by charging_station_location
		___
    	ORDER BY charging_cost
    -- Alias the result as minimum_cost
    ) ___ ___
    
FROM ELECTRIC_VEHICLES.charging;
Kodu Düzenle ve Çalıştır