LoslegenKostenlos loslegen

Next station

Wielding window functions effectively is like having a superpower. You can achieve results much faster.

In this exercise, you will use window functions to provide additional information for passengers aboard a train. In particular, you will use the train_schedule table to also provide the name of the next station, a common form of information that gives commuters time to prepare for the next stop.

Diese Übung ist Teil des Kurses

Time Series Analysis in PostgreSQL

Kurs anzeigen

Anleitung zur Übung

  • Create a new field next_station that gives the name of the next stop for each stop on the train line.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

-- Give the name of the station for the next stop
SELECT
  train_id,
  station,
  ___ ___ (
	PARTITION BY ___
	ORDER BY ___) AS next_station
FROM train_schedule
ORDER BY train_id, arrival_time;
Code bearbeiten und ausführen