By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE [dbo].[tblA](
[id] [int] NULL,
[date1] [date] NULL,
[date2] [date] NULL,
[value] [int] NULL
) ON [PRIMARY]
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2014-01-01' AS Date), CAST(N'2004-01-01' AS Date), 100)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2014-01-01' AS Date), CAST(N'2004-01-01' AS Date), 50)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2014-01-01' AS Date), CAST(N'2009-01-01' AS Date), 10)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2014-01-01' AS Date), CAST(N'2009-01-01' AS Date), 22)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2014-01-01' AS Date), CAST(N'2016-01-01' AS Date), 32)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2015-01-01' AS Date), CAST(N'2004-01-01' AS Date), 12)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2015-01-01' AS Date), CAST(N'2004-01-01' AS Date), 100)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2015-01-01' AS Date), CAST(N'2009-01-01' AS Date), 54)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2015-01-01' AS Date), CAST(N'2009-01-01' AS Date), 32)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2015-01-01' AS Date), CAST(N'2016-01-01' AS Date), 67)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2017-01-01' AS Date), CAST(N'2004-01-01' AS Date), 17)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2017-01-01' AS Date), CAST(N'2004-01-01' AS Date), 14)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2017-01-01' AS Date), CAST(N'2009-01-01' AS Date), 240)
INSERT [dbo].[tblA] ([id], [date1], [date2], [value]) VALUES (1, CAST(N'2017-01-01' AS Date), CAST(N'2009-01-01' AS Date), 254)
id | date1 | date2 | value |
---|---|---|---|
1 | 01/01/2014 00:00:00 | 01/01/2004 00:00:00 | 100 |
1 | 01/01/2015 00:00:00 | 01/01/2004 00:00:00 | 100 |
1 | 01/01/2017 00:00:00 | 01/01/2016 00:00:00 | 300 |