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.
Este exercício faz parte do curso
Writing Functions and Stored Procedures in SQL Server
Instruções do exercício
- Use
DATENAME()
toSELECT
theweekday
value for theStartDate
. - Use
SUM()
andDATEDIFF()
to calculateTotalTripHours
. (beginning with seconds). - Group by the
DATENAME()
result and summarizeTotalTripHours
. - Order
TotalTripHours
in descending order.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
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