1. Învăţa
  2. /
  3. Courses
  4. /
  5. Writing Functions and Stored Procedures in SQL Server

Connected

exercise

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.

Instrucţiuni

100 XP
  • 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.