Session Ready
Exercise

Downsample to a weekly grain

Management would like to see how well people have utilized the spa in 2020. They would like to see results by week, reviewing the total number of minutes of amenity usage, the number of attendees, and the customer with the largest customer ID that week to see if new customers are coming in.

We can use functions in SQL Server to downsample to a fixed grain like this. One such function is DATEPART().

Instructions
100 XP
  • Downsample the day spa visit data to a weekly grain using the DATEPART() function.
  • Find the customer with the largest customer ID for a given week.
  • Fill in the GROUP BY clause with any non-aggregated values in the SELECT clause (but without aliases like AS Week).