Skip to content
Advertisement

Min & Max date before disruption

In Oracle, I have this table sample :

What I’d like to have is this :

HR only send me the sick leaves of employees month by month and I don’t really know how to aggregate those dates, so that I could have only 1 record for 1 “real” sick leave, knowing that there would be no disruption between two months. I’ve read about LAG() but I could not find any way to get the job done.

I am not sure ‘disruption’ in my title is the best way to phrase it so please, feel free to edit it/help me to improve it.

Thank you for your time.

Edit : I’m working with Oracle 18C

Advertisement

Answer

You can use the lag and sum windows function with GROUP BY as follows:

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