Find the outliers
The previous exercise showed us that Saturday was the busiest day of the month for BikeShare rides. Do you wonder if there were any individual Saturday outliers that contributed to this?
Deze oefening maakt deel uit van de cursus
Writing Functions and Stored Procedures in SQL Server
Oefeninstructies
- Use
SUM()andDATEDIFF()to find the Total Ride Hours per day starting from seconds. - Use
CONVERT()toSELECTthe date portion ofStartDate. - Use
DATENAME()andCONVERT()to select theWEEKDAY. - Use
WHEREto only include Saturdays.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
SELECT
-- Calculate TotalRideHours using SUM() and DATEDIFF()
___(___(___, StartDate, EndDate))/ 3600 AS TotalRideHours,
-- Select the DATE portion of StartDate
___(___, StartDate) AS DateOnly,
-- Select the WEEKDAY
___(___, ___(___, StartDate)) AS DayOfWeek
FROM CapitalBikeShare
-- Only include Saturday
WHERE ___(___, StartDate) = 'Saturday'
GROUP BY CONVERT(DATE, StartDate);