|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 5:01 AM
Points: 42,
Visits: 121
|
|
Number weeks of work
Hi there.
I should check that the the number weeks of work for the five names is the same for all... that is, there can not be a person who works more or less of other...
I create a table `tbl_dates` where the primary key is the date and another field used for the holiday.
How do distribute equally these five names for the working weeks in the year?
Can you help me? Any suggestions? thank you in advance
-- ---------------------------- -- Table structure for [dbo].[tbl_dates] -- ---------------------------- DROP TABLE [dbo].[tbl_dates] GO CREATE TABLE [dbo].[tbl_dates] ( [Dates] date NOT NULL , [Holidays] date NULL , [DayDates] varchar(20) NULL , [DayHolidays] varchar(20) NULL )
GO
-- ---------------------------- -- Records of tbl_dates -- ---------------------------- INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-02', N'2013-01-01', N'mercoledì', N'martedì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-03', N'2013-04-01', N'giovedì', N'lunedì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-04', N'2013-04-25', N'venerdì', N'giovedì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-07', N'2013-05-01', N'lunedì', N'mercoledì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-08', N'2013-08-15', N'martedì', N'giovedì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-09', N'2013-11-01', N'mercoledì', N'venerdì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-10', N'2013-12-25', N'giovedì', N'mercoledì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-11', N'2013-12-26', N'venerdì', N'giovedì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-14', N'2013-12-31', N'lunedì', N'martedì'); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-15', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-16', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-17', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-18', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-21', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-22', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-23', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-24', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-25', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-28', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-29', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-30', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-01-31', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-01', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-04', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-05', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-06', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-07', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-08', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-11', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-12', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-13', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-14', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-15', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-18', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-19', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-20', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-21', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-22', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-25', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-26', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-27', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-02-28', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-01', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-04', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-05', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-06', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-07', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-08', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-11', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-12', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-13', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-14', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-15', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-18', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-19', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-20', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-21', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-22', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-25', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-26', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-27', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-28', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-03-29', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-02', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-03', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-04', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-05', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-08', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-09', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-10', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-11', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-12', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-15', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-16', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-17', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-18', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-19', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-22', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-23', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-24', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-26', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-29', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-04-30', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-02', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-03', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-06', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-07', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-08', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-09', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-10', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-13', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-14', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-15', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-16', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-17', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-20', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-21', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-22', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-23', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-24', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-27', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-28', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-29', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-30', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-05-31', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-03', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-04', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-05', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-06', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-07', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-10', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-11', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-12', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-13', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-14', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-17', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-18', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-19', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-20', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-21', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-24', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-25', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-26', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-27', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-06-28', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-01', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-02', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-03', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-04', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-05', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-08', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-09', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-10', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-11', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-12', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-15', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-16', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-17', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-18', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-19', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-22', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-23', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-24', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-25', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-26', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-29', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-30', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-07-31', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-01', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-02', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-05', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-06', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-07', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-08', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-09', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-12', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-13', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-14', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-16', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-19', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-20', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-21', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-22', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-23', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-26', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-27', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-28', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-29', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-08-30', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-02', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-03', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-04', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-05', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-06', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-09', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-10', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-11', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-12', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-13', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-16', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-17', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-18', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-19', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-20', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-23', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-24', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-25', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-26', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-27', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-09-30', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-01', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-02', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-03', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-04', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-07', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-08', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-09', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-10', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-11', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-14', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-15', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-16', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-17', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-18', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-21', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-22', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-23', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-24', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-25', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-28', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-29', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-30', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-10-31', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-04', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-05', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-06', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-07', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-08', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-11', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-12', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-13', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-14', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-15', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-18', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-19', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-20', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-21', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-22', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-25', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-26', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-27', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-28', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-11-29', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-02', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-03', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-04', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-05', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-06', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-09', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-10', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-11', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-12', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-13', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-16', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-17', null, N'martedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-18', null, N'mercoledì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-19', null, N'giovedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-20', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-23', null, N'lunedì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-27', null, N'venerdì', null); GO INSERT INTO [dbo].[tbl_dates] ([Dates], [Holidays], [DayDates], [DayHolidays]) VALUES (N'2013-12-30', null, N'lunedì', null); GO
-- ---------------------------- -- Indexes structure for table tbl_dates -- ----------------------------
-- ---------------------------- -- Primary Key structure for table [dbo].[tbl_dates] -- ---------------------------- ALTER TABLE [dbo].[tbl_dates] ADD PRIMARY KEY ([Dates]) GO
-- ---------------------------- -- Table structure for [dbo].[tbl_names] -- ---------------------------- DROP TABLE [dbo].[tbl_names] GO CREATE TABLE [dbo].[tbl_names] ( [names] varchar(50) NULL , [id] int NOT NULL IDENTITY(1,1) )
GO DBCC CHECKIDENT(N'[dbo].[tbl_names]', RESEED, 5) GO
-- ---------------------------- -- Records of tbl_names -- ---------------------------- SET IDENTITY_INSERT [dbo].[tbl_names] ON GO INSERT INTO [dbo].[tbl_names] ([names], [id]) VALUES (N'George', N'1'); GO INSERT INTO [dbo].[tbl_names] ([names], [id]) VALUES (N'Laura', N'2'); GO INSERT INTO [dbo].[tbl_names] ([names], [id]) VALUES (N'Martin', N'3'); GO INSERT INTO [dbo].[tbl_names] ([names], [id]) VALUES (N'Arnold', N'4'); GO INSERT INTO [dbo].[tbl_names] ([names], [id]) VALUES (N'Betty', N'5'); GO SET IDENTITY_INSERT [dbo].[tbl_names] OFF GO
-- ---------------------------- -- Indexes structure for table tbl_names -- ----------------------------
-- ---------------------------- -- Primary Key structure for table [dbo].[tbl_names] -- ---------------------------- ALTER TABLE [dbo].[tbl_names] ADD PRIMARY KEY ([id]) GO
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 1:51 PM
Points: 32,906,
Visits: 26,789
|
|
cms9651 (12/23/2012) Number weeks of work
Hi there.
I should check that the the number weeks of work for the five names is the same for all... that is, there can not be a person who works more or less of other...
I create a table `tbl_dates` where the primary key is the date and another field used for the holiday.
How do distribute equally these five names for the working weeks in the year?
Can you help me? Any suggestions? thank you in advance
Not enough info. Are these 5 folks supposed to work a full week while the others are off? Are these 5 folks supposed to work just one day and then not again for 5 business days? O ????
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 5:01 AM
Points: 42,
Visits: 121
|
|
thank you for reply.
one of five people have to work a full week, while others are off. everyone has to work the same number of weeks for year.
know what I mean?
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Today @ 2:41 PM
Points: 1,456,
Visits: 14,257
|
|
cms9651 (12/24/2012) thank you for reply.
one of five people have to work a full week, while others are off. everyone has to work the same number of weeks for year.
know what I mean?
is this some form of "scheduling"?
last time I counted there were 52 weeks in a year divided by 5 workers = 10.4 weeks each so if I read your request correctly ...I dont see how everyone can work same number of weeks in a year?
can be done by number of days (ie 73 per worker) except in a leap year 
__________________________________________________________________ you can lead a user to data....but you cannot make them think ! __________________________________________________________________
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 5:01 AM
Points: 42,
Visits: 121
|
|
J Livingston SQL (12/24/2012)
cms9651 (12/24/2012) thank you for reply.
one of five people have to work a full week, while others are off. everyone has to work the same number of weeks for year.
know what I mean?is this some form of "scheduling"? last time I counted there were 52 weeks in a year divided by 5 workers = 10.4 weeks each so if I read your request correctly ...I dont see how everyone can work same number of weeks in a year? can be done by number of days (ie 73 per worker) except in a leap year 
Ok I understand your explication... but in my case I counted 50 weeks in a year divided by 5 workers = 10 weeks each because for two week for year is vacation 
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 1:51 PM
Points: 32,906,
Visits: 26,789
|
|
cms9651 (12/24/2012) thank you for reply.
one of five people have to work a full week, while others are off. everyone has to work the same number of weeks for year.
know what I mean?
Sure... so what do you want to do about 3 and 4 day work weeks? Do those count as a full week?
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 5:01 AM
Points: 42,
Visits: 121
|
|
Yes, Sir.
In my case I counted 50 weeks in a year divided by 5 workers = 10 weeks each because for two week for year is vacation.
1. I need everyone to work an equal number of weeks (10 weeks for year); 2. Every week work is five consecutive working days;
e.g. George working in the week 07, 08, 09, 10 and 11 january 2013 the next turn of work for George is 11, 12, 13, 14 and 15 february 2013 because previous week:
a. Laura 14-15-16-17-18 january 2013 b. Martin 21-22-23-24-25 january 2013 c. Arnold 28-29-30-31 january 2013 and 01 february 2013 d. Betty 04-05-06-07-08 february 2013
In my case employees are off every weekend.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 6:28 PM
Points: 2,340,
Visits: 3,168
|
|
My first suggestion to you would be to remove the tbl_ from your table names as I find that convention totally annoying. You're not programming C or C# here, so there is no need to prefix the object type on the name. SSMS does a pretty good job of segregating objects and doesn't get confused on that point.
Perhaps this query will get you started:
;WITH GroupsOfWeeks AS ( SELECT * ,n=1+(((ROW_NUMBER() OVER (ORDER BY Dates)-1)/5) % 5) FROM [dbo].[tbl_dates] ) SELECT Dates, Holidays, DayDates, DayHolidays, names FROM GroupsOfWeeks INNER JOIN [dbo].[tbl_names] ON n = id ORDER BY Dates
It distributes the names across alternating weeks, with each person assigned to 5 consecutive days in your dates table. Since there are 251 rows in this table, George gets to work an extra day.
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead? Since random numbers are too important to be left to chance, let's generate some! Are you too recursively challenged? Splitting strings based on patterns can be fast!
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 5:01 AM
Points: 42,
Visits: 121
|
|
dwain.c (12/24/2012)
My first suggestion to you would be to remove the tbl_ from your table names as I find that convention totally annoying. You're not programming C or C# here, so there is no need to prefix the object type on the name. SSMS does a pretty good job of segregating objects and doesn't get confused on that point. Perhaps this query will get you started: ;WITH GroupsOfWeeks AS ( SELECT * ,n=1+(((ROW_NUMBER() OVER (ORDER BY Dates)-1)/5) % 5) FROM [dbo].[tbl_dates] ) SELECT Dates, Holidays, DayDates, DayHolidays, names FROM GroupsOfWeeks INNER JOIN [dbo].[tbl_names] ON n = id ORDER BY Dates
It distributes the names across alternating weeks, with each person assigned to 5 consecutive days in your dates table. Since there are 251 rows in this table, George gets to work an extra day.
Thank you very much for your suggestion. I tried your query and I have this output. The problem is when a legal holiday occurs in the week you see the output:
First week of the year:
2013-01-01 holiday 2013-01-02 2013-01-03 2013-01-04
Is a three day week and in this case count as a complete week... I need this output it's possible?
Dates DayDates names 2013-01-02 mercoledì George 2013-01-03 giovedì George 2013-01-04 venerdì George 2013-01-07 lunedì Laura 2013-01-08 martedì Laura
Will the company then compensate economically for any difference of days worked. Cheers.
WITH GroupsOfWeeks AS ( SELECT * ,n=1+(((ROW_NUMBER() OVER (ORDER BY Dates)-1)/5) % 5) FROM [dbo].[dates] ) SELECT Dates, DayDates, [names] FROM GroupsOfWeeks INNER JOIN [dbo].[names] ON n = id ORDER BY Dates
Dates DayDates names 2013-01-02 mercoledì George 2013-01-03 giovedì George 2013-01-04 venerdì George 2013-01-07 lunedì George 2013-01-08 martedì George
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 6:28 PM
Points: 2,340,
Visits: 3,168
|
|
cms9651 (12/25/2012)
dwain.c (12/24/2012)
My first suggestion to you would be to remove the tbl_ from your table names as I find that convention totally annoying. You're not programming C or C# here, so there is no need to prefix the object type on the name. SSMS does a pretty good job of segregating objects and doesn't get confused on that point. Perhaps this query will get you started: ;WITH GroupsOfWeeks AS ( SELECT * ,n=1+(((ROW_NUMBER() OVER (ORDER BY Dates)-1)/5) % 5) FROM [dbo].[tbl_dates] ) SELECT Dates, Holidays, DayDates, DayHolidays, names FROM GroupsOfWeeks INNER JOIN [dbo].[tbl_names] ON n = id ORDER BY Dates
It distributes the names across alternating weeks, with each person assigned to 5 consecutive days in your dates table. Since there are 251 rows in this table, George gets to work an extra day. Thank you very much for your suggestion. I tried your query and I have this output. The problem is when a legal holiday occurs in the week you see the output: First week of the year: 2013-01-01 holiday 2013-01-02 2013-01-03 2013-01-04
Is a three day week and in this case count as a complete week... I need this output it's possible? Dates DayDates names 2013-01-02 mercoledì George 2013-01-03 giovedì George 2013-01-04 venerdì George 2013-01-07 lunedì Laura 2013-01-08 martedì Laura
Will the company then compensate economically for any difference of days worked. Cheers. WITH GroupsOfWeeks AS ( SELECT * ,n=1+(((ROW_NUMBER() OVER (ORDER BY Dates)-1)/5) % 5) FROM [dbo].[dates] ) SELECT Dates, DayDates, [names] FROM GroupsOfWeeks INNER JOIN [dbo].[names] ON n = id ORDER BY Dates
Dates DayDates names 2013-01-02 mercoledì George 2013-01-03 giovedì George 2013-01-04 venerdì George 2013-01-07 lunedì George 2013-01-08 martedì George
Have you tried adding a WHERE clause before ORDER BY that excludes holidays?
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead? Since random numbers are too important to be left to chance, let's generate some! Are you too recursively challenged? Splitting strings based on patterns can be fast!
|
|
|
|