this topic did help me in the past:
i ended up using dnoets olap function (how typical). however the period functions should also solve this. the olap function is ansi standard. the period approach is teradata specific.
Thanks Johannes for responding so quicly.
we got it.