The LEAD and LAG aggregate functions and what to do when you don’t have them

I recently worked with an insurance company on an interesting issue involving dates. They had a series of records that all had a start date but no end (or cancel) date. The end date of a record was implicitly recognized as the start date of the next highest record.

For example, a table called IMPORTANT_THINGS:

agg1.png

The first record is effective for customer number 1 beginning on January 1, 2017 and ending on January 1, 2018. We have a frequent need to represent that on a single row of a result set. The goal is to produce the following result:

agg2.png

To find out how, check out the full article below. 

https://www.idug.org/p/bl/ar/blogaid=846

Recent Stories
October Content recap

Deprecated Objects and APPLCOMPAT

Running Db2 for z/OS utilities from the application programs (DSNUTILU as a piece of DevOps)