LoslegenKostenlos loslegen

Which day of week is busiest?

Now that we verified there are seconds consistently in our dataset we can calculate the Total Trip Time for each day of the week.

Diese Übung ist Teil des Kurses

Writing Functions and Stored Procedures in SQL Server

Kurs anzeigen

Anleitung zur Übung

  • Use DATENAME() to SELECT the weekday value for the StartDate.
  • Use SUM() and DATEDIFF() to calculate TotalTripHours. (beginning with seconds).
  • Group by the DATENAME() result and summarize TotalTripHours.
  • Order TotalTripHours in descending order.

Interaktive Übung

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

SELECT
    -- Select the day of week value for StartDate
	___(___, StartDate) as DayOfWeek,
    -- Calculate TotalTripHours
	___(___(___, StartDate, EndDate))/ 3600 as TotalTripHours 
FROM CapitalBikeShare 
-- Group by the day of week
GROUP BY ___(___, StartDate)
-- Order TotalTripHours in descending order
ORDER BY ___ DESC
Code bearbeiten und ausführen