Exercise

Logical weekdays with Hot Deck

Calculate Total Fare Amount per Total Distance for each day of week. If the TripDistance is zero use the Hot Deck imputation function you created earlier in the chapter.

Instructions

100 XP
  • Use DATENAME() and PickupDate to select the day of week.
  • Use AVG() to calculate TotalAmount per TripDistance, and a CASE statement to select TripDistance if it's more than 0. If not, use dbo.GetTripDistanceHotDeck().
  • Order by the PickupDate day of week, with 'Monday' appearing first.