【发布时间】:2020-10-06 00:44:09
【问题描述】:
我有一个包含开始日期和结束日期的表格,我需要将记录拆分为按天计算,这需要放在视图中。
| PersonID | CompanyID | Start_DT | End_DT |
|-----------|--------------|-------------|-----------|
| A12 | abc | 05-01-2020 | 05-03-2020|
| B23 | def | 06-08-2020 | 06-14-2020|
| PersonID | CompanyID | New_DT |
|-----------|--------------|-------------|
| A12 | abc | 05-01-2020 | ==> A12 Start Date is 05-01-2020 and End Date is 05-03-2020. So there are 3 records generated in New_DT
| A12 | abc | 05-02-2020 |
| A12 | abc | 05-03-2020 |
| B23 | def | 06-08-2020 |
| B23 | def | 06-09-2020 |
| B23 | def | 06-10-2020 |
| B23 | def | 06-11-2020 |
| B23 | def | 06-12-2020 |
| B23 | def | 06-13-2020 |
| B23 | def | 06-14-2020 |
如何在 View 中实现这一点?
【问题讨论】:
-
你试过什么?你在哪里卡住了?这是一个相当普遍的问题。
-
此问题中的两个答案与“解决方案”链接中的答案不同
标签: sql snowflake-cloud-data-platform sql-view sql-date-functions sqldatetime