Back to problems

Cumulative Monthly Sales by Store with Month Reset

SQL · Tesla · Medium

You are given a sales table with the columns date, store_id, and amount. Calculate the running sales total separately for each store, starting over at the beginning of every calendar month. In other words, compute a cumulative sum within each store_id and month. Requirements: Produce the result with one SQL query. Return store_id, date, total_amount, where total_amount represents that store's cumulative sales from the start of the current month through the given date. Scale…

Checking your access…