Skip to content

Tag: window-functions

Lead window function in mysql to find sales

Given this table. I would like to know for each day how many different customers made a sale on date t and and t+1. The result for date 2021-06-30 is 2 because customer 1 and 3 made a sale in t and t+1. Answer Use LEAD() window function for each distinct combination of date and customer to create a flag