sql server - How could I "auto-rotate" appended records in SQL (1 goes to 2, 2 goes 3, 3 goes to 4, 4 goes back to 1)? -
I'm working on system (ASP.NET / MSSQL/C#) to schedule restaurant staff.
The problem I need to "auto-rotate" in "Intimes" every week.
The user should be able to copy the schedule for one day in the next week, while all the employees rotated one place at the time of shift. For example, in the table below, Monica will have 10: Monday changes at 30, then next week at 11:00, and Adam will arrive from 12:00 to 10:30 in the morning.
The time between Pali is not constant, nor is the number of employees in every change.
Any thoughts on how to do it (with the ideal SQL statement) would be highly appreciated.
Please keep in mind that I am a relative newbie.
RecordID EmpType Date Day Mile ShiftOrder Intime EmployeeID 1 Server 29-Aug-11 Monday afternoon 1 10:30. : 00 AM Monica 2 server 29-Aug-11 Monday afternoon 2:00 am 11:00:00 am Sofia 3 server 29-Aug-11 Monday afternoon 3 11:30:00 AM Janie 4 server 29-Aug-11 Monday afternoon 4 o'clock 12:00:00 pm Adam 5 Server 29-Aug-11 Monday Dinner 1 4:30 pm Afam 6 Servers 29-Aug-11 Monday Night 2 4:45:00 Prime Minister Jenny 7 Server 29-Aug-11 Monday night dinner 3 5: 00:00 PM Shauna 8 Server 29-Aug-11 Monday to dinner 4 5:15:00 PM Sophia 10 Server 29-August -11 Monday night 5 5:30:00 Monica
In some way an employee can To get the last (some) changes
Top selection will be required 3- Where to shift from 'EmployeeID' to 'Monica' Order [Date] DESC Next to enter that time / time Before the date he wants to do next week for a program, relative work will need to offset. Choose the change INSERT rdID, [date], case [Intime] when [intime] between '00:00 and 10:00' then 'snack' when [intime] then ' Lunch 'between [Intime] between 04:30 to 10:01 and then eating 4:29 and 23:59 again, as No_idea_how_to_generate_this ShiftOrder, [Intime], from' EmployeeID 'as' Dinner' end ( Select as zero recordID, DATEADD (day, 7 + @ dateoffset, ls [date]) [date], in the form of cast (DATEADD (minute, @timeoffset, ls time [time] as in time.) [Intime ], Where from the EmployeeID shift in the form of recordID = @recordID) SubSylect
here: - @recordID is the record that the employee chooses as the starting point for a new appointment.
- @dateoffset is the number of days to add an initial record - @timeoffset is the number of minutes to add to the initial record All the rest were used as the starting point Line.
Comments
Post a Comment