Skip to content
Advertisement

teradata, reset when, partition by, order by

I need help understanding the below code. I have never seen reset when used in Teradata. What does RESET WHEN do in Teradata? I understand the partition and order by part. I was also unsure why this wasn’t partitioned by PARTITION BY A.ACCT_DIM_NB, A.DAY_TIME_DIM_NB ORDER BY A.TXN_POSTING_SEQ . Also, is ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW just using the whole partitioned window?

Advertisement

Answer

I was also unsure why this wasn’t partitioned by PARTITION BY Y.ACCT_DIM_NB, Y.DAY_TIME_DIM_NB ORDER BY Y.DAY_TIME_DIM_NB, Y.TXN_POSTING_SEQ

Don’t know, but this would return a different result (and Y.DAY_TIME_DIM_NB is not needed in ORDER BY because it’s already partitioned by it)

Also, is ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW just using the whole partitioned window?

It’s exactly the same as ROWS UNBOUNDED PRECEDING, i.e. a syntax variation for a Cumulative Max. The lpartition is ROWS UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING

What does RESET WHEN do in Teradata?

The RESET WHEN is a Teradata extension for dynamically adding partitions, it’s a shorter syntax for two (in your case) or three nested OLAP functions:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement