Teradata-无法折叠重叠的行并保留间隙

时间:2018-10-08 21:48:50

标签: teradata

给出这个可爱的数据集,其中包含各种空白和重叠的记录:

env:
- $RESOLVER="lts-6.35"
- $RESOLVER="lts-7.24"
- $RESOLVER="lts-9.21"
- $RESOLVER="lts-10.3"
- $RESOLVER="lts-11.22"
- $RESOLVER="lts-12.11"
if: branch = master
- $RESOLVER="nightly"     # Exclude from hackage branch

if: $RESOLVER = "nightly"
- $STACKYAML="post86.yaml"
if: $RESOLVER != "nightly"
- $STACKYAML="pre86.yaml"

在保留空白和更改的同时如何折叠重叠部分? 第1行和第2行之间有间隙。 第3行到第5行重叠。 第6和第7行重叠。

它最终应为:

+---+--------+------+-------+-------+-----------+------------+------------+
|   | BUS_LN | SGMT | STATE | TheID | ASSGND_TO |   EFF_DT   |   END_DT   |
+---+--------+------+-------+-------+-----------+------------+------------+
| 1 | A      | B    | LA    | 12345 | AAA       | 2015-01-01 | 2015-06-30 |
| 2 | A      | B    | LA    | 12345 | AAA       | 2015-10-01 | 2015-12-31 |
| 3 | A      | B    | LA    | 12345 | AAA       | 2016-01-01 | 2016-02-29 |
| 4 | A      | B    | LA    | 12345 | AAA       | 2016-03-01 | 2017-12-31 |
| 5 | A      | B    | LA    | 12345 | AAA       | 2018-01-01 | 9999-12-31 |
| 6 | A      | B    | LA    | 67890 | BBB       | 2015-01-01 | 2016-01-01 |
| 7 | A      | B    | LA    | 67890 | BBB       | 2016-01-01 | 2017-01-01 |
| 8 | A      | B    | LA    | 67890 | CCC       | 2017-01-01 | 2018-01-01 |
| 9 | A      | B    | LA    | 67890 | BBB       | 2018-01-01 | 9999-12-31 |
+---+--------+------+-------+-------+-----------+------------+------------+

我整天都走在各个不同的圈子,最近一次使用的文档功能令人难以置信的+--------+------+-------+-------+-----------+------------+------------+ | BUS_LN | SGMT | STATE | TheID | ASSGND_TO | EFF_DT | END_DT | +--------+------+-------+-------+-----------+------------+------------+ | A | B | LA | 12345 | AAA | 2015-01-01 | 2015-06-30 | | A | B | LA | 12345 | AAA | 2015-10-01 | 9999-12-31 | | A | B | LA | 67890 | BBB | 2015-01-01 | 2017-01-01 | | A | B | LA | 67890 | CCC | 2017-01-01 | 2018-01-01 | | A | B | LA | 67890 | BBB | 2018-01-01 | 9999-12-31 | +--------+------+-------+-------+-----------+------------+------------+ 功能很差,但是我却一无所获。

1 个答案:

答案 0 :(得分:0)

看看Teradata的时间功能: -它提供了PERIOD数据类型(而不是两个日期字段) -它提供标准化/爆炸/重叠/汇总有效日期期限的功能。