Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Calculate different days of activity from overlapping date ranges

idea.mpJan 30 2018 — edited Jan 30 2018

Hi,

I have a table with ranges of date:

Activity IDCustomer IDStart DateEnd Date
11231 may 201715 june 2017
245610 may 201718 july 2017
312320 may 201720 june 2017
41231 january 201720 january 2017

I have to create a function that return the number of different days of activity from this table. So, if a day is in two or more ranges I have to count it one time only.

In this case, for Customer ID = 123, the function may return 46, because the days between 20 may and 15 june in activity IDs 1 and 3 are counted one time only.

Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2018
Added on Jan 30 2018
9 comments
713 views