除了最后一列之外,所有列都在表中。最后一栏是我之后的,你如何编写代码来获取当前表?
DATE DataQuarter DataMonth DataWeek DayTypeInd DayTypeDesc DayName HolidayName workday Next B day
12/29/2016 2016-Q4 2016-12 2016-53 1 WEEKDAY Thursday NULL 1 12/30/2016
12/30/2016 2016-Q4 2016-12 2016-53 1 WEEKDAY Friday NULL 1 1/3/2017
12/31/2016 2016-Q4 2016-12 2016-53 2 WEEKEND Saturday NULL 0 1/3/2017
1/1/2017 2017-Q1 2017-01 2017-01 2 WEEKEND Sunday NEW YEAR 0 1/3/2017
1/2/2017 2017-Q1 2017-01 2017-01 1 WEEKDAY Monday NULL 0 1/3/2017
1/3/2017 2017-Q1 2017-01 2017-01 1 WEEKDAY Tuesday NULL 1 1/4/2017
1/4/2017 2017-Q1 2017-01 2017-01 1 WEEKDAY Wednesday NULL 1 1/5/2017
答案 0 :(得分:0)
只要您预先计算了WorkDay列,就可以使用以下选项。
Select [Date],
DataQuarter,
DataMonth,
DataWeek,
DayTypeInd,
DayTypeDesc,
[DayName],
HolidayName,
WorkDay,
(Select Min([Date]) From MyTable T2 where T2.[Date] > T1.[Date] and T2.WorkDay = 1) as [Next B Day]
From MyTable T1