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:


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:


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

Recent Stories
Cardinality Without Runstats

Jenkins Pipeline H2 Database Integration Testing

December Content Recap