【发布时间】:2021-12-08 16:27:51
【问题描述】:
我有一个包含以下列的表格:customerID、startdate、enddate。例如:
CustomerID startdate(mm/dd/yyyy) Enddate(mm/dd/yyyy)
c1 10-15-2020 10-18-2020
c2 02-20-2021 02-25-2021
c3 12-01-2021 12-08-2021
如何编写 SQL 查询来分别展开每个客户的开始日期和结束日期之间的所有日期?
所以预期的输出是:
CustomerID exploedcalendardate
c1 10-15-2020
c1 10-16-2020
c1 10-17-2020
c1 10-18-2020
c2 02-20-2021
c2 02-21-2021
c2 02-22-2021
c2 02-23-2021
c2 02-24-2021
c2 02-25-2021
c3 12-01-2021
c3 12-02-2021
c3 12-03-2021
c3 12-04-2021
c3 12-05-2021
c3 12-06-2021
c3 12-07-2021
c3 12-08-2021
【问题讨论】:
-
Redshift 还是 Postgres?它们是两种截然不同的产品。
标签: sql postgresql amazon-redshift