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

En uzun boşluk

Evanston 311 taleplerinin gönderilmesi arasındaki en uzun süre nedir?

lead() ve lag() için sözdizimini hatırla:

lag(column_to_adjust) OVER (ORDER BY ordering_column)
lead(column_to_adjust) OVER (ORDER BY ordering_column)

Bu egzersiz

SQL ile Keşifsel Veri Analizi

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

Egzersiz talimatları

  • Uygun şekilde lead() veya lag() kullanarak date_created ile önceki talebin date_created değerini seç.
  • Her talep ile bir önceki talep arasındaki boşluğu (farkı) hesapla.
  • En büyük boşluğa sahip satırı seç.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

-- Compute the gaps
WITH request_gaps AS (
        SELECT date_created,
               -- lead or lag
               ___(date_created) OVER (___) AS previous,
               -- compute gap as date_created minus lead or lag
               date_created - ___(date_created) OVER (___) AS gap
          FROM evanston311)
-- Select the row with the maximum gap
SELECT *
  FROM request_gaps
-- Subquery to select maximum gap from request_gaps
 WHERE gap = (SELECT ___
                FROM request_gaps);
Kodu Düzenle ve Çalıştır