I am working on a request that will return the proposed start date for the production line based on the set date and the number of minutes required to complete the task.
There is a calendar table (LINE_ID, CALENDAR_DATE, SCHEDULED_MINUTES), which is displayed on each production line, the number of minutes scheduled for this day.
Example: (Usually 3 shifts cost time per day, seven days a week, but may vary)
1, 06/8/2010 00:00:00.000, 1440
1, 06/7/2010 00:00:00.000, 1440
1, 06/6/2010 00:00:00.000, 0
1, 06/5/2010 00:00:00.000, 0
1, 06/4/2010 00:00:00.000, 1440
To get the suggested start date, I need to start from the set date and iterate down for days until I have enough time to complete the task.
My question may be how it is done with CTE, or this is what should be handled by the cursor. Or ... am I just going completely different?
source
share