सबसे लंबा अंतराल
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);