【发布时间】:2020-01-14 07:09:41
【问题描述】:
我有一个带有date 列和system_week_end 日期列的 MySQL。 system_week_end列有一两周缺失值的情况。
注意
-
system_week_end可以是一周中的任何一天。我无法结束标准周末功能 -
system_week_end是按company列过滤的子集,每个公司都设置了system_week_end日期。 -
date列包含每天,没有缺失值。
以下是数据示例:
date system_week_end
2020-01-05 2020-01-05
2020-01-04 <null>
2020-01-03 <null>
2020-01-02 <null>
2020-01-01 <null>
2019-12-31 <null>
2019-12-30 <null>
2019-12-29 <null>
2019-12-28 <null>
2019-12-27 <null>
2019-12-26 <null>
2019-12-25 <null>
2019-12-24 <null>
2019-12-23 <null>
2019-12-22 2019-12-22
2019-12-21 <null>
2019-12-20 <null>
2019-12-19 <null>
2019-12-18 <null>
2019-12-17 <null>
2019-12-16 <null>
2019-12-15 2019-12-15
我将如何构造一个 MySQL 查询来为 system_week_end 列填充 null?
例如:
2020-01-05 2020-01-05
2020-01-04 2020-01-05
2020-01-03 2020-01-05
2020-01-02 2020-01-05
2020-01-01 2020-01-05
2019-12-31 2020-01-05
2019-12-30 2020-01-05
2019-12-29 2019-12-29
2019-12-28 2019-12-29
2019-12-27 2019-12-29
2019-12-26 2019-12-29
2019-12-25 2019-12-29
2019-12-24 2019-12-29
2019-12-23 2019-12-29
2019-12-22 2019-12-22
2019-12-21 2019-12-22
2019-12-20 2019-12-22
2019-12-19 2019-12-22
2019-12-18 2019-12-22
2019-12-17 2019-12-22
2019-12-16 2019-12-22
2019-12-15 2019-12-15
【问题讨论】:
-
抱歉,不清楚您在问什么。也许在你做任何事情之后添加一个你想要对这些行发生的事情的例子
-
找到给定日期的周末日期并不难。谷歌会帮助你。
-
system_week_end 可以是任何工作日,因此我无法结束 std 周末功能。
-
那么对于对应
system_week_end的每个日期都为NULL,你想要它的周末日期吗? -
@mitkosoft 正确。
system_weekend_date并不总是日历周末。此数据是使用where company = ...的子集