शुरू करेंमुफ़्त में शुरू करें

सबसे लंबा अंतराल

Evanston 311 रिक्वेस्ट के सबमिट होने के बीच सबसे लंबा समय कितना है?

lead() और lag() का सिंटैक्स याद करें:

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

यह अभ्यास पाठ्यक्रम का हिस्सा है

SQL में Exploratory Data Analysis

पाठ्यक्रम देखें

अभ्यास निर्देश

  • lead() या lag() का उपयुक्त रूप से उपयोग करके date_created और पिछली रिक्वेस्ट का date_created चुनें.
  • हर रिक्वेस्ट और पिछली रिक्वेस्ट के बीच का गैप निकालें.
  • अधिकतम गैप वाली पंक्ति चुनें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

-- 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);
कोड संपादित करें और चलाएँ