【发布时间】:2021-06-02 14:51:27
【问题描述】:
我有一张如下表:
ID Amt type accnum rcnum amt
1 Recovery type 1 [NULL] 45
1 Total recovery [NULL] 34
1 Current Type 1 2345 123 23
1 Total current type [NULL] 12
1 Current type 1 [NULL] 78
1 Current rvrsl [NULL] -908
现在我想创建如下,它总结了每种类型的 amt,但如果存在则填充有效值,否则将填充 NULL/空白:
ID Amt type accnum rcnum amt
1 Recovery type 1 [NULL] 45
1 Total recovery [NULL] 34
1 Current Type 1 2345 123 101
1 Total current type [NULL] 12
1 Current rvrsl [NULL] -908
我正在尝试进行左连接,但我不确定如何在不删除其他记录的情况下实现此目的。
【问题讨论】:
标签: sql group-by amazon-redshift