Skip to content
Advertisement

adding values based on date range sql

Stuck on the problem below.

Desired output:

The data has many employees across thousands of dates so it needs be done in a way where weeks are added based off the day_one column. I have used a lag/lead but if an employee has an 8 week cycle it becomes very inefficient. The code below gives the week_num =1, repeating gives 2 etc.

And level 2 to the problem. Current data:

Desired output (repeating cycles):

Advertisement

Answer

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement