保留价值直到teradata中的某个日期

时间:2018-06-18 05:41:49

标签: teradata

以下是我之前发布的链接。它的工作方式是社区成员之一@Doneth的建议。 但是当我在coalesce中使用'2018-05-31'时,我收到的错误是'if / then else语句中'数据类型不匹配'。

使用的查询:

with cte 
{
  SELECT customer_id, bal, st_ts,
      -- return the next row's date
      Coalesce(Min(st_ts)
               Over (PARTITION BY customer_id 
                     ORDER BY st_ts
                     ROWS BETWEEN 1 Following AND 1 Following)
              ,'2018-05-31') AS next_Txn_dt
   FROM BAL_DET;
}
SELECT customer_id, bal
  ,Last(pd) -- last day of the period
FROM cTE
-- make a period of the current and next row's date
-- and return one row per day
EXPAND ON PERIOD(ST_TS, next_Txn_dt) AS pd;

链接到我的问题: Retain values till there is a change in value in Teradata

0 个答案:

没有答案