시작하기무료로 시작하기

충전 세션의 지속 시간과 비용 시각화

데이터 시각화 팀이 충전 데이터를 새로운 방식으로 분석하고 싶어 해요. 특정 날짜에 특정 충전소 위치에서 각 충전의 지속 시간을 더 잘 이해하려고 합니다. 또한 각 충전 세션의 비용을 해당 충전소 위치의 평균 충전 비용과 비교하고 싶어 해요. 이 정보를 시각화할 수 있도록 사용할 데이터셋을 준비해 주세요!

이 연습은 강의의 일부입니다

Snowflake의 Window 함수

강의 보기

연습 안내

  • 창 함수(window function)를 사용해 각 charging_station_location에서 모든 세션의 charging_duration이 총합에서 차지하는 비율을 구하세요.
  • 각 세션의 충전 비용과 해당 charging_station_location의 평균 charging_cost 차이를 계산하고, 결과를 cost_vs_avg로 별칭(alias) 지정하세요.
  • 결과를 charging_station_locationcharging_date로 정렬하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

SELECT
    charging_station_location,
    TO_DATE(charging_start_time) AS charging_date,
    charging_duration,
    charging_cost,
	
    -- Find the proportion of total charging duration charging location
    charging_duration / ___(___) OVER(
        PARTITION BY ___
    ) AS proportion_of_daily_charging_duration,
	
    -- Determine the difference between each session's charging 
    -- cost and the average charging cost for each charging station location
    charging_cost - ___(___) OVER (
        PARTITION BY ___
    ) AS ___

FROM ELECTRIC_VEHICLES.charging

-- Order the results by charging station location and charging date
ORDER BY ___, ___;
코드 편집 및 실행