Date gaps between date spans

  • Hi All,

    Edit - managed to edit the original post.

    I have data that I need to find missing date gaps - below is sample data.

    There are multiple GroupId's, each having a start and end date - I need to find out where there are spans missing between the start date and end date.

    If we look at groupid 26112, there are 2 rows, row 1 has an end date of 2015-06-26 00:00:00.000 row 2 has a start date of 2015-08-24 00:00:00.000, so this means there is a gap and I need to fill this gap with another row with a start date of 2015-06-27 and an enddate of

    2015-08-24.

    Would someone be able to point me in the right direction?

    Many thanks

    Michael

    CREATE TABLE [dbo].[zzz_SSC_Help](

    [GroupID] [varchar](50) NULL,

    [Category] [varchar](255) NULL,

    [StartDate] [datetime] NULL,

    [EndDate] [datetime] NULL

    ) ON [PRIMARY]

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'21519', N'Offer with Wait', CAST(N'2004-06-09 00:00:00.000' AS DateTime), CAST(N'2015-05-08 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'21519', N'Offer with Wait', CAST(N'2015-10-26 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'22338', N'No Offer', CAST(N'2013-01-17 00:00:00.000' AS DateTime), CAST(N'2015-01-18 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'22338', N'Offer with Wait', CAST(N'2015-01-19 00:00:00.000' AS DateTime), CAST(N'2015-11-09 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'26112', N'Offer with Wait', CAST(N'2001-11-09 00:00:00.000' AS DateTime), CAST(N'2015-06-26 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'26112', N'Offer with Wait', CAST(N'2015-08-24 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'28215', N'Offer with Wait', CAST(N'2008-09-29 00:00:00.000' AS DateTime), CAST(N'2015-04-30 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'28215', N'Offer with Wait', CAST(N'2015-07-29 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'28437', N'Offer with Wait', CAST(N'2012-07-09 00:00:00.000' AS DateTime), CAST(N'2015-07-19 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'28437', N'No Offer', CAST(N'2015-07-20 00:00:00.000' AS DateTime), CAST(N'2015-10-16 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'30053', N'Offer with Wait', CAST(N'2005-08-01 00:00:00.000' AS DateTime), CAST(N'2015-04-19 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'30053', N'No Offer', CAST(N'2015-08-01 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'30433', N'No Offer', CAST(N'2012-12-05 00:00:00.000' AS DateTime), CAST(N'2015-01-18 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'30433', N'Offer with Wait', CAST(N'2015-01-19 00:00:00.000' AS DateTime), CAST(N'2015-10-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'30973', N'Offer with Wait', CAST(N'2006-07-01 00:00:00.000' AS DateTime), CAST(N'2015-01-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'30973', N'No Offer', CAST(N'2015-01-05 00:00:00.000' AS DateTime), CAST(N'2015-05-29 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'31778', N'Offer with Wait', CAST(N'2007-02-08 00:00:00.000' AS DateTime), CAST(N'2015-02-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'31778', N'Offer with Wait', CAST(N'2015-07-20 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'32000', N'Offer with Wait', CAST(N'2007-05-21 00:00:00.000' AS DateTime), CAST(N'2015-02-13 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'32000', N'Offer with Wait', CAST(N'2015-08-31 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'33111', N'Offer with Wait', CAST(N'2008-04-07 00:00:00.000' AS DateTime), CAST(N'2015-02-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'33111', N'No Offer', CAST(N'2015-02-16 00:00:00.000' AS DateTime), CAST(N'2015-08-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'33157', N'Offer with Wait', CAST(N'2008-04-28 00:00:00.000' AS DateTime), CAST(N'2015-04-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'33157', N'No Offer', CAST(N'2015-04-13 00:00:00.000' AS DateTime), CAST(N'2015-09-11 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'33625', N'Offer with Wait', CAST(N'2008-08-11 00:00:00.000' AS DateTime), CAST(N'2015-01-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'33625', N'No Offer', CAST(N'2015-01-05 00:00:00.000' AS DateTime), CAST(N'2015-10-22 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'34943', N'Offer with Wait', CAST(N'2009-11-16 00:00:00.000' AS DateTime), CAST(N'2015-03-29 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'34943', N'No Offer', CAST(N'2015-03-30 00:00:00.000' AS DateTime), CAST(N'2015-05-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'34972', N'Offer with Wait', CAST(N'2009-12-07 00:00:00.000' AS DateTime), CAST(N'2015-07-23 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'34972', N'No Offer', CAST(N'2015-09-12 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'34997', N'Offer with Wait', CAST(N'2009-12-21 00:00:00.000' AS DateTime), CAST(N'2015-02-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'34997', N'No Offer', CAST(N'2015-02-16 00:00:00.000' AS DateTime), CAST(N'2015-12-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'35003', N'Offer with Wait', CAST(N'2009-12-28 00:00:00.000' AS DateTime), CAST(N'2015-07-08 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'35003', N'No Offer', CAST(N'2015-10-19 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'35121', N'Offer with Wait', CAST(N'2010-03-08 00:00:00.000' AS DateTime), CAST(N'2015-05-10 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'35121', N'No Offer', CAST(N'2015-05-11 00:00:00.000' AS DateTime), CAST(N'2015-09-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36300', N'Offer with Wait', CAST(N'2011-05-16 00:00:00.000' AS DateTime), CAST(N'2015-05-10 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36300', N'No Offer', CAST(N'2015-05-11 00:00:00.000' AS DateTime), CAST(N'2015-09-14 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36300', N'No Offer', CAST(N'2015-12-07 00:00:00.000' AS DateTime), CAST(N'2015-12-20 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36300', N'Offer with Wait', CAST(N'2015-12-21 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36347', N'Offer with Wait', CAST(N'2011-06-06 00:00:00.000' AS DateTime), CAST(N'2015-03-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36347', N'No Offer', CAST(N'2015-03-16 00:00:00.000' AS DateTime), CAST(N'2015-08-11 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36922', N'No Offer', CAST(N'2011-10-24 00:00:00.000' AS DateTime), CAST(N'2015-07-05 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36922', N'Offer with Wait', CAST(N'2015-07-06 00:00:00.000' AS DateTime), CAST(N'2015-08-14 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36966', N'Offer with Wait', CAST(N'2011-11-15 00:00:00.000' AS DateTime), CAST(N'2015-01-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'36966', N'No Offer', CAST(N'2015-01-05 00:00:00.000' AS DateTime), CAST(N'2015-03-07 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37425', N'Offer with Wait', CAST(N'2012-06-25 00:00:00.000' AS DateTime), CAST(N'2015-02-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37425', N'No Offer', CAST(N'2015-02-02 00:00:00.000' AS DateTime), CAST(N'2015-03-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37544', N'Offer with Wait', CAST(N'2012-07-02 00:00:00.000' AS DateTime), CAST(N'2015-07-17 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37544', N'Offer with Wait', CAST(N'2015-10-14 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37704', N'No Offer', CAST(N'2012-07-17 00:00:00.000' AS DateTime), CAST(N'2015-04-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37704', N'Offer with Wait', CAST(N'2015-10-28 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37812', N'Offer with Wait', CAST(N'2012-08-21 00:00:00.000' AS DateTime), CAST(N'2015-01-19 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'37812', N'Offer with Wait', CAST(N'2015-10-26 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38024', N'Offer with Wait', CAST(N'2014-04-14 00:00:00.000' AS DateTime), CAST(N'2015-03-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38024', N'No Offer', CAST(N'2015-11-16 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38128', N'Offer with Wait', CAST(N'2013-01-07 00:00:00.000' AS DateTime), CAST(N'2015-05-10 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38128', N'No Offer', CAST(N'2015-05-11 00:00:00.000' AS DateTime), CAST(N'2015-10-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38224', N'Offer with Wait', CAST(N'2013-02-21 00:00:00.000' AS DateTime), CAST(N'2015-03-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38224', N'No Offer', CAST(N'2015-03-02 00:00:00.000' AS DateTime), CAST(N'2015-07-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38265', N'Offer with Wait', CAST(N'2013-03-07 00:00:00.000' AS DateTime), CAST(N'2015-07-19 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38265', N'No Offer', CAST(N'2015-07-20 00:00:00.000' AS DateTime), CAST(N'2015-08-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38267', N'Offer with Wait', CAST(N'2013-03-11 00:00:00.000' AS DateTime), CAST(N'2015-03-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38267', N'Offer with Wait', CAST(N'2015-05-25 00:00:00.000' AS DateTime), CAST(N'2015-11-22 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38267', N'No Offer', CAST(N'2015-11-23 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38482', N'Offer with Wait', CAST(N'2013-06-03 00:00:00.000' AS DateTime), CAST(N'2015-02-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38482', N'No Offer', CAST(N'2015-02-02 00:00:00.000' AS DateTime), CAST(N'2015-04-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38520', N'Offer with Wait', CAST(N'2013-06-03 00:00:00.000' AS DateTime), CAST(N'2015-03-14 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38520', N'No Offer', CAST(N'2015-11-30 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38591', N'No Offer', CAST(N'2013-06-17 00:00:00.000' AS DateTime), CAST(N'2015-02-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38591', N'Offer with Wait', CAST(N'2015-02-02 00:00:00.000' AS DateTime), CAST(N'2015-10-08 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38709', N'Offer with Wait', CAST(N'2013-07-02 00:00:00.000' AS DateTime), CAST(N'2015-05-10 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38709', N'No Offer', CAST(N'2015-05-11 00:00:00.000' AS DateTime), CAST(N'2015-12-07 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38934', N'No Offer', CAST(N'2013-07-14 00:00:00.000' AS DateTime), CAST(N'2015-06-07 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'38934', N'Offer with Wait', CAST(N'2015-06-08 00:00:00.000' AS DateTime), CAST(N'2015-11-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39061', N'Offer with Wait', CAST(N'2013-08-05 00:00:00.000' AS DateTime), CAST(N'2015-03-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39061', N'No Offer', CAST(N'2015-03-02 00:00:00.000' AS DateTime), CAST(N'2015-03-08 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39193', N'Offer with Wait', CAST(N'2013-09-03 00:00:00.000' AS DateTime), CAST(N'2015-08-20 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39193', N'Offer with Wait', CAST(N'2015-12-14 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39306', N'Offer with Wait', CAST(N'2013-09-23 00:00:00.000' AS DateTime), CAST(N'2015-09-27 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39306', N'No Offer', CAST(N'2015-09-28 00:00:00.000' AS DateTime), CAST(N'2015-11-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39409', N'No Offer', CAST(N'2013-10-11 00:00:00.000' AS DateTime), CAST(N'2015-03-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39409', N'Offer with Wait', CAST(N'2015-03-02 00:00:00.000' AS DateTime), CAST(N'2015-12-11 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39726', N'Offer with Wait', CAST(N'2013-12-09 00:00:00.000' AS DateTime), CAST(N'2015-09-22 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39726', N'Offer with Wait', CAST(N'2015-12-09 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39785', N'No Offer', CAST(N'2013-12-26 00:00:00.000' AS DateTime), CAST(N'2015-07-05 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39785', N'Offer with Wait', CAST(N'2015-07-06 00:00:00.000' AS DateTime), CAST(N'2015-08-27 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39789', N'Offer with Wait', CAST(N'2013-12-31 00:00:00.000' AS DateTime), CAST(N'2015-06-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39789', N'No Offer', CAST(N'2015-06-22 00:00:00.000' AS DateTime), CAST(N'2015-11-17 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39798', N'Offer with Wait', CAST(N'2014-01-06 00:00:00.000' AS DateTime), CAST(N'2015-10-25 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39798', N'No Offer', CAST(N'2015-10-26 00:00:00.000' AS DateTime), CAST(N'2015-11-10 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39866', N'No Offer', CAST(N'2014-01-23 00:00:00.000' AS DateTime), CAST(N'2015-05-24 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39866', N'Offer with Wait', CAST(N'2015-05-25 00:00:00.000' AS DateTime), CAST(N'2015-09-18 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39883', N'Offer with Wait', CAST(N'2014-01-27 00:00:00.000' AS DateTime), CAST(N'2015-06-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39883', N'No Offer', CAST(N'2015-06-22 00:00:00.000' AS DateTime), CAST(N'2015-10-26 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39901', N'Offer with Wait', CAST(N'2014-02-03 00:00:00.000' AS DateTime), CAST(N'2015-05-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'39901', N'Offer with Wait', CAST(N'2015-08-10 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40006', N'Offer with Wait', CAST(N'2014-03-03 00:00:00.000' AS DateTime), CAST(N'2015-05-10 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40006', N'No Offer', CAST(N'2015-05-11 00:00:00.000' AS DateTime), CAST(N'2015-11-18 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40011', N'Offer with Wait', CAST(N'2014-03-03 00:00:00.000' AS DateTime), CAST(N'2015-06-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40011', N'No Offer', CAST(N'2015-06-22 00:00:00.000' AS DateTime), CAST(N'2015-08-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40306', N'No Offer', CAST(N'2014-05-13 00:00:00.000' AS DateTime), CAST(N'2015-02-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40306', N'Offer with Wait', CAST(N'2015-02-02 00:00:00.000' AS DateTime), CAST(N'2015-05-13 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40331', N'No Offer', CAST(N'2014-05-20 00:00:00.000' AS DateTime), CAST(N'2015-06-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40331', N'Offer with Wait', CAST(N'2015-06-22 00:00:00.000' AS DateTime), CAST(N'2015-09-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40371', N'Offer with Wait', CAST(N'2014-06-02 00:00:00.000' AS DateTime), CAST(N'2015-09-27 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40371', N'No Offer', CAST(N'2015-09-28 00:00:00.000' AS DateTime), CAST(N'2015-11-26 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40380', N'Offer with Wait', CAST(N'2014-06-02 00:00:00.000' AS DateTime), CAST(N'2015-01-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40380', N'Offer with Wait', CAST(N'2015-04-13 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40441', N'No Offer', CAST(N'2014-06-12 00:00:00.000' AS DateTime), CAST(N'2015-06-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40441', N'Offer with Wait', CAST(N'2015-07-20 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40446', N'Offer with Wait', CAST(N'2014-06-16 00:00:00.000' AS DateTime), CAST(N'2015-08-02 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40446', N'No Offer', CAST(N'2015-08-03 00:00:00.000' AS DateTime), CAST(N'2015-12-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40469', N'Offer with Wait', CAST(N'2014-06-17 00:00:00.000' AS DateTime), CAST(N'2015-04-26 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40469', N'No Offer', CAST(N'2015-04-27 00:00:00.000' AS DateTime), CAST(N'2015-07-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40476', N'Offer with Wait', CAST(N'2014-06-17 00:00:00.000' AS DateTime), CAST(N'2015-02-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40476', N'No Offer', CAST(N'2015-04-06 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40705', N'Offer No Wait', CAST(N'2014-07-01 00:00:00.000' AS DateTime), CAST(N'2015-04-14 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40705', N'Offer No Wait', CAST(N'2015-12-08 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40924', N'No Offer', CAST(N'2014-07-28 00:00:00.000' AS DateTime), CAST(N'2015-01-18 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'40924', N'Offer with Wait', CAST(N'2015-01-19 00:00:00.000' AS DateTime), CAST(N'2015-03-18 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41061', N'Offer with Wait', CAST(N'2014-09-11 00:00:00.000' AS DateTime), CAST(N'2015-04-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41061', N'No Offer', CAST(N'2015-04-13 00:00:00.000' AS DateTime), CAST(N'2015-06-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41090', N'Offer with Wait', CAST(N'2014-09-15 00:00:00.000' AS DateTime), CAST(N'2015-11-22 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41090', N'No Offer', CAST(N'2015-11-23 00:00:00.000' AS DateTime), CAST(N'2015-11-23 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41119', N'No Offer', CAST(N'2014-09-29 00:00:00.000' AS DateTime), CAST(N'2015-04-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41119', N'Offer with Wait', CAST(N'2015-04-13 00:00:00.000' AS DateTime), CAST(N'2015-06-26 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41178', N'Offer with Wait', CAST(N'2014-10-13 00:00:00.000' AS DateTime), CAST(N'2015-03-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41178', N'No Offer', CAST(N'2015-03-16 00:00:00.000' AS DateTime), CAST(N'2015-09-23 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41181', N'Offer with Wait', CAST(N'2014-10-13 00:00:00.000' AS DateTime), CAST(N'2015-02-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41181', N'No Offer', CAST(N'2015-02-02 00:00:00.000' AS DateTime), CAST(N'2015-04-29 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41204', N'Offer with Wait', CAST(N'2014-10-20 00:00:00.000' AS DateTime), CAST(N'2015-06-07 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41204', N'No Offer', CAST(N'2015-06-08 00:00:00.000' AS DateTime), CAST(N'2015-08-17 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41223', N'No Offer', CAST(N'2014-10-21 00:00:00.000' AS DateTime), CAST(N'2015-08-02 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41223', N'Offer with Wait', CAST(N'2015-08-03 00:00:00.000' AS DateTime), CAST(N'2015-10-06 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41329', N'Offer with Wait', CAST(N'2014-11-17 00:00:00.000' AS DateTime), CAST(N'2015-07-05 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41329', N'No Offer', CAST(N'2015-07-06 00:00:00.000' AS DateTime), CAST(N'2015-09-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41413', N'No Offer', CAST(N'2014-12-08 00:00:00.000' AS DateTime), CAST(N'2015-08-02 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41413', N'Offer with Wait', CAST(N'2015-08-03 00:00:00.000' AS DateTime), CAST(N'2015-12-04 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41436', N'No Offer', CAST(N'2014-12-15 00:00:00.000' AS DateTime), CAST(N'2015-06-07 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41436', N'Offer with Wait', CAST(N'2015-06-08 00:00:00.000' AS DateTime), CAST(N'2015-07-24 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41449', N'Offer with Wait', CAST(N'2014-12-15 00:00:00.000' AS DateTime), CAST(N'2015-05-24 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41449', N'No Offer', CAST(N'2015-05-25 00:00:00.000' AS DateTime), CAST(N'2015-05-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41464', N'Offer with Wait', CAST(N'2014-12-15 00:00:00.000' AS DateTime), CAST(N'2015-09-27 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41464', N'No Offer', CAST(N'2015-09-28 00:00:00.000' AS DateTime), CAST(N'2015-10-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41500', N'Offer with Wait', CAST(N'2014-12-29 00:00:00.000' AS DateTime), CAST(N'2015-03-17 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41500', N'Offer with Wait', CAST(N'2015-12-07 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41560', N'No Offer', CAST(N'2015-01-15 00:00:00.000' AS DateTime), CAST(N'2015-03-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41560', N'Offer with Wait', CAST(N'2015-03-16 00:00:00.000' AS DateTime), CAST(N'2015-04-14 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41584', N'Offer with Wait', CAST(N'2015-01-21 00:00:00.000' AS DateTime), CAST(N'2015-09-13 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41584', N'No Offer', CAST(N'2015-09-14 00:00:00.000' AS DateTime), CAST(N'2015-10-21 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41653', N'Offer with Wait', CAST(N'2015-02-09 00:00:00.000' AS DateTime), CAST(N'2015-08-30 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41653', N'No Offer', CAST(N'2015-08-31 00:00:00.000' AS DateTime), CAST(N'2015-10-19 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41751', N'No Offer', CAST(N'2015-03-09 00:00:00.000' AS DateTime), CAST(N'2015-08-02 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41751', N'Offer with Wait', CAST(N'2015-08-03 00:00:00.000' AS DateTime), CAST(N'2015-11-30 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41772', N'No Offer', CAST(N'2015-03-16 00:00:00.000' AS DateTime), CAST(N'2015-05-24 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41772', N'Offer with Wait', CAST(N'2015-05-25 00:00:00.000' AS DateTime), CAST(N'2015-07-30 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41799', N'No Offer', CAST(N'2015-03-17 00:00:00.000' AS DateTime), CAST(N'2015-04-12 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41799', N'Offer with Wait', CAST(N'2015-04-13 00:00:00.000' AS DateTime), CAST(N'2015-05-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41852', N'No Offer', CAST(N'2015-04-01 00:00:00.000' AS DateTime), CAST(N'2015-05-24 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41852', N'Offer with Wait', CAST(N'2015-05-25 00:00:00.000' AS DateTime), CAST(N'2015-10-25 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41924', N'Offer with Wait', CAST(N'2015-04-20 00:00:00.000' AS DateTime), CAST(N'2015-06-01 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41924', N'Offer with Wait', CAST(N'2015-09-28 00:00:00.000' AS DateTime), CAST(N'9999-12-31 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41930', N'Offer with Wait', CAST(N'2015-04-20 00:00:00.000' AS DateTime), CAST(N'2015-09-27 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41930', N'No Offer', CAST(N'2015-09-28 00:00:00.000' AS DateTime), CAST(N'2015-11-09 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41967', N'No Offer', CAST(N'2015-04-27 00:00:00.000' AS DateTime), CAST(N'2015-07-05 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'41967', N'Offer with Wait', CAST(N'2015-07-06 00:00:00.000' AS DateTime), CAST(N'2015-12-28 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'42023', N'No Offer', CAST(N'2015-05-11 00:00:00.000' AS DateTime), CAST(N'2015-06-07 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'42023', N'Offer with Wait', CAST(N'2015-06-08 00:00:00.000' AS DateTime), CAST(N'2015-10-15 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'42744', N'No Offer', CAST(N'2015-08-18 00:00:00.000' AS DateTime), CAST(N'2015-10-11 00:00:00.000' AS DateTime))

    GO

    INSERT [dbo].[zzz_SSC_Help] ([GroupID], [Category], [StartDate], [EndDate]) VALUES (N'42744', N'Offer with Wait', CAST(N'2015-10-12 00:00:00.000' AS DateTime), CAST(N'2015-11-16 00:00:00.000' AS DateTime))

    GO

  • Hi All,

    Edit - please ignore this post - apologies for confusion.

    Sorry, for some reason when I hit preview it posted and when editing the post, I get no option to actually post the edit.

    I have data that I need to find missing date gaps - below is sample data.

    There are multiple GroupId's, each having a start and end date - I need to find out where there are spans missing between the start date and end date.

    Would someone be able to point me in the right direction?

    Many thanks

    Michael

  • This is a classic gaps/islands problem. Have a look at this article:

    https://www.simple-talk.com/sql/t-sql-programming/the-sql-of-gaps-and-islands-in-sequences/[/url]

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • Quick solution for SQL Server 2008

    😎

    First add this POC index

    CREATE NONCLUSTERED INDEX NCLIDX_DBO_ZZZ_SSC_HELP_GROUP_STARTDATE ON dbo.zzz_SSC_Help (GroupID ASC, StartDate ASC) INCLUDE (EndDate);

    The query

    ;WITH BASE_DATA AS

    (

    SELECT

    ROW_NUMBER() OVER

    (

    PARTITION BY SSC.GroupID

    ORDER BY SSC.StartDate

    ) AS GRINST_ID

    ,SSC.GroupID

    ,SSC.StartDate

    ,SSC.EndDate

    FROM [dbo].[zzz_SSC_Help] SSC

    )

    SELECT

    BD_FROM.GroupID

    ,DATEDIFF(DAY, BD_FROM.EndDate,BD_TO.StartDate) GAP_IN_DAYS

    FROM BASE_DATA BD_FROM

    INNER JOIN BASE_DATA BD_TO

    ON BD_FROM.GroupID = BD_TO.GroupID

    AND BD_FROM.GRINST_ID = BD_TO.GRINST_ID - 1

    WHERE DATEDIFF(DAY, BD_FROM.EndDate,BD_TO.StartDate) > 1

    ;

    Output from the test data

    GroupID GAP_IN_DAYS

    ---------- -----------

    21519 171

    26112 59

    28215 90

    30053 104

    31778 164

    32000 199

    34972 51

    35003 103

    36300 84

    37544 89

    37704 205

    37812 280

    38024 255

    38267 74

    38520 261

    39193 116

    39726 78

    39901 90

    40380 75

    40441 49

    40476 61

    40705 238

    41500 265

    41924 119

  • Alan and Eirikur thank you so much for the help, really appreciate it.

    Below has giving me exactly what I need.

    Thanks again.

    Michael

    ;WITH BASE_DATA AS

    (

    SELECT

    ROW_NUMBER() OVER

    (

    PARTITION BY SSC.GroupID

    ORDER BY SSC.StartDate

    ) AS GRINST_ID

    ,SSC.GroupID

    ,SSC.StartDate

    ,SSC.EndDate

    FROM [dbo].[zzz_SSC_Help] SSC

    )

    SELECT

    BD_FROM.GroupID,

    dateadd(D,1,BD_FROM.EndDate) as Gap_StartDate,

    dateadd(D,-1,BD_TO.StartDate) as Gap_Enddate,

    DATEDIFF(DAY, BD_FROM.EndDate,BD_TO.StartDate) GAP_IN_DAYS

    FROM BASE_DATA BD_FROM

    INNER JOIN BASE_DATA BD_TO

    ON BD_FROM.GroupID = BD_TO.GroupID

    AND BD_FROM.GRINST_ID = BD_TO.GRINST_ID - 1

    WHERE DATEDIFF(DAY, BD_FROM.EndDate,BD_TO.StartDate) > 1

    ;

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply